hdu1907
这道题要对全部为1的情况特判,因为这种情况下与一般的nim游戏下不同
//============================================================================
// Name : hdu1907.cpp
// Author :
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <cstdio>
using namespace std;
int N, n, ans, tag;
int a[100];
int main() {
scanf("%d", &N);
while(N--){
scanf("%d", &n);
ans = 0;
tag = 0;
for(int i = 0;i < n;i++){
scanf("%d", &a[i]);
if(a[i]!=1)
tag = 1;
}
if(tag)
{
for(int i = 0;i < n;i++){
ans ^= a[i];
}
if(ans == 0) printf("Brother\n");
else printf("John\n");
}
else{
if(n%2 == 0) printf("John\n");
else printf("Brother\n");
}
}
return 0;
}

浙公网安备 33010602011771号