详解见:http://wenku.baidu.com/link?url=H7XaRgujsbyWo3lQS5G2kXzzTgs-vS3-RvW3mVLEpKAjUgC94vPrBfkCXi4zxiavztczFR4-rk7X8h-ATZ_Xn_-5P0vRyV3f6LdZEeb6-YW
http://www.doc88.com/p-15628486495.html
里面有各种推论(博弈)
题目:http://acm.hdu.edu.cn/showproblem.php?pid=1907(反Nim)
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cstdio>
using namespace std;
int main()
{
int t;
scanf("%d",&t);
int n, x, cnt, ans = 0;
while(t--){
while(~scanf("%d", &n))
{
ans = 0;
cnt = 0;
for(int i = 0; i < n; ++i)
{
scanf("%d", &x);
ans ^= x;
cnt += (x>1);
}
if((ans==0&&cnt==0)||(ans!=0&&cnt>=1)) puts("John");
else puts("Brother");
}
}
return 0;
}
同类型还有hdu 2509,
Nim 游戏:hdu 1524、hdu 1944、hdu 1536、hdu 5795