详解见::hdu 1907 John - lihaogegehuting的专栏 - 博客频道 - youkuaiyun.com
两道题一样。。。
代码如下:
#include<stdio.h>
int main()
{
int T,a[100],i,sum,m,ok;
while(~scanf("%d",&T))
{
while(T--)
{
sum=0;
ok=0;
scanf("%d",&m);
for(i=1;i<=m;i++)
{
scanf("%d",&a[i]);
if(a[i]>1) ok=1;
sum=sum^a[i];
}
if(ok==0)
{
if(m%2==0)
printf("John\n");
else
printf("Brother\n");
}
else
if(sum==0)
printf("Brother\n");
else
printf("John\n");
}
}
return 0;
}