/*
有SJ 定理:对于任意的一个 Anti-SG 游戏,如果我们规定当局面中所有单一游戏的 SG 值为 0 时游戏
结束,则先手必胜当且仅当以下两个条件满足任意一个:
(1)游戏的 SG 函数不为 0,且游戏中某个单一游戏的 SG 函数大于1。
(2)游戏的 SG 函数为 0,且游戏中没有单一游戏的 SG 函数大于 1。*/#include <cstdio>int T;
int N;int main()
{int a,ans,k;scanf("%d",&T);while(T--){scanf("%d",&N);k = 0;ans = 0;for(int i=0;i<N;i++){scanf("%d",&a);if(a>1) k++;ans ^= a;}if(k==0){if(!ans) printf("John\n");else printf("Brother\n");}else{if(ans) printf("John\n");else printf("Brother\n");}}return 0;
}
转载于:https://www.cnblogs.com/ac2012/archive/2011/06/13/2080032.html