标签:长度 etc div lld ref lan argv argc har
二次联通门 : 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; }
标签:长度 etc div lld ref lan argv argc har
原文地址:http://www.cnblogs.com/ZlycerQan/p/7061897.html