Anti-nim博弈 John poj3480
来源:互联网 发布:淘宝卖家编辑宝贝尺码 编辑:程序博客网 时间:2024/06/05 10:12
传送门:点击打开链接
题意:和nim游戏一样,只不过取最后一个石子的人输。
思路:有一个SJ定理,是专门用来求Anti-nim游戏的,如下
SJ定理
SG函数的求法一模一样,最后如果只有一堆,也能用SJ定理
如果为Anti-Nim游戏,如下情况先手胜
SG异或和为0,且单个游戏的SG全部<=1
SG异或不为0,且存在单个游戏的SG>1,即<=1的个数不等于独立游戏个数
#include<map>#include<set>#include<cmath>#include<ctime>#include<stack>#include<queue>#include<cstdio>#include<cctype>#include<string>#include<vector>#include<cstring>#include<iostream>#include<algorithm>#include<functional>#define fuck(x) cout<<"["<<x<<"]"#define FIN freopen("input.txt","r",stdin)#define FOUT freopen("output.txt","w+",stdout)using namespace std;typedef long long LL;const int MX = 100 + 5;int A[MX];/*SJ定理SG函数的求法一模一样,最后如果只有一堆,也能用SJ定理如果为Anti-Nim游戏,如下情况先手胜SG异或和为0,且单个游戏的SG全部<=1SG异或不为0,且存在单个游戏的SG>1,即<=1的个数不等于独立游戏个数*/int main() { int T, n; scanf("%d", &T); while(T--) { scanf("%d", &n); int sum = 0, cnt = 0; for(int i = 1; i <= n; i++) { scanf("%d", &A[i]); sum ^= A[i]; cnt += (A[i] <= 1); } if(sum == 0 && cnt == n) printf("John\n"); else if(sum != 0 && cnt != n) printf("John\n"); else printf("Brother\n"); } return 0;}
0 0
- Anti-nim博弈 John poj3480
- poj3480 John (nim博弈变形--SJ定理)
- POJ 3480 John Anti-Nim博弈变形
- HDOJ 1907 John anti-nim博弈
- 【POJ3480】John 博弈 Anti-SG misère规则尼姆游戏
- anti-nim博弈
- UVA 1566 - John(anti-Nim)
- hdu 1907 John(anti-nim)
- Nim博弈变形(anti-nim)
- 【poj3480】John
- [BZOJ1022][SHOI2008]小约翰的游戏John(博弈Anti-Nim游戏)
- HDOJ 1907 John nim博弈
- HDU 1907 John Nim博弈
- HDU 1907 Nim博弈 John
- HDOJ 1907 John (nim博弈)
- POJ 3480 John (Nim博弈)
- HDU 1907 John (Nim博弈)
- poj 3480 John anti-SG博弈
- 如何使用Ubuntu Night配置sources.list
- 分别使用java和JS获取某月的第一天和最后一天
- vitual box 及 ubuntu 安装及使用教程以及常见error
- Linux设备驱动程序
- UIBezierPath Class Reference翻译
- Anti-nim博弈 John poj3480
- Android类动态加载技术
- jQuery的deferred对象详解
- 解决ubuntu E: Encountered a section with no Package: header
- 1221: [HNOI2001] 软件开发
- Oracle复习
- OSX下代码打开系统首选项(system preferences)
- 个人遇到的浏览器兼容性
- 【Html】隐性改变display类型