题目:http://www.lydsy.com/JudgeOnline/problem.php?id=1022
代码(NIM类型的博弈题):
#include <cstdio>
int t,n,f;
int main(){
scanf("%d",&t);
while (t--){
scanf("%d",&n);
f=0;
bool flag=true;
for (int i=0;i++<n;){
int x;
scanf("%d",&x);
f^=x;
if (x!=1){
flag=false;
}
}
if (flag){
if (n%2==0) printf("John\n"); else printf("Brother\n");
} else
if (f){
printf("John\n");
} else printf("Brother\n");
}
return 0;
}