题目:链接:http://acm.hdu.edu.cn/showproblem.php?pid=1907
题意:
思路:
和Nimm博弈不同的是输赢规则。
代码:
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int t;
int n,m,sum,cnt;
int main()
{
cin>>t;
while(t--)
{
cin>>n;
sum = 0;
cnt = 0;
for(int i=0; i<n; i++)
{
cin>>m;
if(m>1)//第一次就面对奇异局势,必赢。。
cnt = 1;
sum ^= m;
}
if(cnt)
{
if(sum)
cout<<"John";
else
cout<<"Brother";
}
else
{
if(sum)
cout<<"Brother";
else
cout<<"John";
}
cout<<endl;
}
return 0;
}