luogu P3799 妖梦拼木棒
Posted ZlycerQan
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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; }
以上是关于luogu P3799 妖梦拼木棒的主要内容,如果未能解决你的问题,请参考以下文章