tjut 4664
来源:互联网 发布:gpt安装ubuntu 编辑:程序博客网 时间:2024/04/29 05:46
include <cstdio> #include <cstring> typedef long long ll; #define N 1002 bool vis[N]; int sg[N]; int a[] = {4,8,1,1,2,0,3,1,1,0,3,3,2,2,4,4,5,5,9,3,3,0,1,1,3,0,2,1,1,0,4,5,3,7}; int SG(int x) { if (sg[x] != -1) return sg[x]; if (x == 0) return 0; if (x == 1) return 0; if (x == 2) return 1; if (x == 3) return 1; memset(vis, false, sizeof(vis)); for (int i=0; i<x-1; i++) vis[SG(i)^SG(x-i-2)] = true; for (int i=0; ;i++) if (!vis[i]) return i; } int get_sg(int x) { if (x <= 100) return sg[x]; return a[x%34]; } int main() { memset(sg, -1, sizeof(sg)); for (int i=0; i<=100; i++) sg[i] = SG(i); int T, n, x; scanf("%d", &T); while (T--) { scanf("%d", &n); int ans = 0; while (n--) { scanf("%d", &x); ans ^= get_sg(x); } puts(ans ? "Carol" : "Dave"); } return 0; }
0 0
- tjut 4664
- 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
- c json解析jansson
- poj1426——Find The Multiple(BFS)
- ML_1_SVM算法
- Android文件目录,线性布局以及基本控件
- SQL Server2008创建约束图解 唯一性约束
- tjut 4664
- 广搜
- Eclipse 2015优化技巧
- C++primer plus第4-6章笔记
- 转载 读取配置文件(.ini)
- 暴力匹配算法与KMP算法(串的匹配)
- boost使用学习总结
- Android手机签核 Eclipse+VS2010+MSSQL
- Netty教程