初学者可以借鉴 http://blog.csdn.net/acm_cxlove/article/details/7854530 博弈讲得比较清楚。
#include <cstring>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
int n,m;
int main()
{
int cas,x,ans,t;
scanf("%d",&cas);
while(cas--)
{
scanf("%d",&n);
ans=t=x=0;
for(int i=1;i<=n;i++)
{
scanf("%d",&x);
ans^=x;
if(x>1) t++;
}
if ((ans==0 && t>=2) || (ans!=0 && t==0))
{
printf("Brother\n");
}
else
{
printf("John\n");
}
}
return 0;
}