【BZOJ1022】[SHOI2008]小约翰的游戏John【Anti-Nim】

【题目链接】

传说中的anti-nim...

orz【dzy的blog】

/* Footprints In The Blood Soaked Snow */
#include <cstdio>

inline int iread() {
	int f = 1, x = 0; char ch = getchar();
	for(; ch < '0' || ch > '9'; ch = getchar()) f = ch == '-' ? -1 : 1;
	for(; ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	return f * x;
}

int main() {
	for(int T = iread(); T; T--) {
		int n = iread(), s1 = 0, s2 = 0;
		for(int i = 1; i <= n; i++) {
			int x = iread();
			s1 ^= x; s2 += x > 1;
		}
		if((s1 && s2) || (!s1 && !s2)) printf("John\n");
		else printf("Brother\n");
	}
	return 0;
}


你可能感兴趣的:(【BZOJ1022】[SHOI2008]小约翰的游戏John【Anti-Nim】)