这是一道裸Anti-Nim游戏
先手必胜条件(满足下面两个其中一个就行):
*每一块石子的数量都为1,且总SG值为0时
*至少有一块石子的数量大于1,且
总SG值不为0时
#include <bits/stdc++.h>
using namespace std;
int a[100];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int t;cin>>t;
while(t--)
{
int n;cin>>n;
int res=0,num=0;
for(int i=1;i<=n;i++)
{
int x;cin>>x;
res^=x;
if(x==1) num++;
}
if(num==n&&res==0||num<n&&res!=0) cout<<"John"<<endl;
else cout<<"Brother"<<endl;
}
return 0;
}