zoukankan      html  css  js  c++  java
  • luogu P3799 妖梦拼木棒

    二次联通门 : luogu P3799 妖梦拼木棒

    /*
        luogu P3799 妖梦拼木棒
        
        用一个桶存下所有的木棒
        
        美剧两根短的木棒长度
        
        后随便乘一乘就 好了。。 
    
    */
    #include <algorithm>
    #include <cstdio>
    
    #define Mod 1000000007
    
    #define Max 5000
    
    void read (int &now)
    {
        now = 0;
        register char word = getchar ();
        while (word < '0' || word > '9')
            word = getchar ();
        while (word >= '0' && word <= '9')
        {
            now = now * 10 + word - '0';
            word = getchar ();
        }
    }
    
    
    int N;
    
    long long count[Max << 1];
    long long Answer;
    
    int main (int argc, char *argv[])
    {
        read (N);
        int x;
        for (register int i = 1; i <= N; i ++)
        {
            read (x);
            count[x] ++;
        }
            
        for (register int i = 1; i <= Max; i ++)
            for (register int j = i; j <= Max; j ++)
            {
                if (i + j > Max)
                    break;
                if (i == j)
                {
                    if (count[i] >= 2 && count[i << 1] >= 2)
                        Answer = (Answer + count[i] * (count[i] - 1) / 2LL % Mod * (count[i << 1] * (count[i << 1] - 1) / 2 % Mod)) % Mod;    
                }
                else
                    if (count[i] >= 1 && count[j] >= 1 && count[i + j] >= 2)
                        Answer = (Answer + (count[i] * count[j] % Mod * (count[i + j] * (count[i + j] - 1) / 2)% Mod)) % Mod;
                    
            }
        
        printf ("%lld", Answer);
        return 0;
    }
  • 相关阅读:
    类加载器ClassLoader
    JAVA分别获取日期中的年、月、日
    sql 安全问题
    马尔科夫链
    触发器、锁、事务和事务控制
    索引、视图、存储过程、函数、游标
    字符集
    数据类型选择
    存储引擎
    错误:too many indices for array
  • 原文地址:https://www.cnblogs.com/ZlycerQan/p/7061897.html
Copyright © 2011-2022 走看看