题目
经典的anti-nim题目。
和普通的nim差不多,判断结局的方式不一样:游戏的SG函数不为0且游戏中某个单一游戏的SG函数值大于1,游戏的SG函数为0且没有某个单一游戏的SG函数大于1,先手必胜。
ac代码:

#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
namespace {
  template <typename T> inline void read(T &x) {
    x = 0; T f = 1;char s = getchar();
    for(; !isdigit(s); s = getchar()) if(s == '-') f = -1;
    for(;  isdigit(s); s = getchar()) x = (x << 3) + (x << 1) + (s ^ 48);
    x *= f;
  }
}
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define _for(n,m,i) for (int i = (n); i < (m); i++)
#define _rep(n,m,i) for (int i = (n); i <= (m); i++)
#define lson rt << 1, l, mid
#define rson rt << 1 | 1, mid + 1, r
#define lowbit(x) x & (-x)
#define pii pair<int,int>
int main() { 
  int n, m, t;
  cin >> t;
  while(t--) { 
    int sgs = 0, cnt = 0;
    cin >> n;
    while(n--) { 
      cin >> m;
      if(m > 1) cnt++;
      sgs ^= m;
    } 
    if(cnt) { 
      if(sgs) cout << "John\n";
      else cout << "Brother\n";
    } 
    else { 
      if(sgs) cout << "Brother\n";
      else cout << "John\n";
    } 
  } 
}