tjut 3049
来源:互联网 发布:点windows键没反应 编辑:程序博客网 时间:2024/06/15 13:21
#include <cstdio> typedef long long LL; const int MOD = 1000003; const int MAXN = 40000 + 10; int N, kase; LL sum; int pow2[MAXN]; void GetPow2() { pow2[0] = 1; for (int i = 1; i < MAXN; ++i) { pow2[i] = (pow2[i - 1] << 1) % MOD; } } void Read() { int n; sum = 0; scanf("%d", &N); for (int i = 0; i < N; ++i) { scanf("%d", &n); sum = (sum + pow2[n]) % MOD; } } void gcd(LL a, LL b, LL& d, LL& x, LL& y) { if (!b) { d = a; x = 1; y = 0; return; } else { gcd(b, a % b, d, y, x); y -= a / b * x; } } LL Inv(int a, int n) { LL ret, d, y; gcd(a, n, d, ret, y); return d == 1 ? (ret + n) % n : -1; } void Solve() { LL ret; LL inv = Inv(N, MOD); ret = sum * inv % MOD; printf("Case %d:%I64d\n", ++kase, ret); } int main() { int T; kase = 0; GetPow2(); scanf("%d", &T); while (T--) { Read(); Solve(); } return 0; }
0 0
- tjut 3049
- tjut 5289
- tjut 5288
- tjut 5294
- tjut 2586
- tjut 5296
- tjut 5297
- tjut 5299
- tjut 5384
- tjut 5387
- tjut 5386
- tjut 5381
- tjut 5400
- tjut 5399
- tjut 5396
- tjut 5398
- tjut 5412
- tjut 5410
- chapter1、计算机技术概述
- hduoj 1166敌兵布阵(树状数组)
- Linux安装Maven本地私有库Sonatype Nexus
- POJ 1837Balance
- windows 异常处理
- tjut 3049
- 思维改变生活
- 1055. The World's Richest (25)-PAT甲级真题
- 切换语言不退出应用
- Oracle中“HINT”的30个用法
- UIWindow小结
- 版本控制工具——git讲解
- Makefile编写的一些小知识
- 【GaoJueYi 2016.08.16初中部 NOIP普及组 】模拟赛总结