您的位置:首页 > 其它

bzoj1022: [SHOI2008]小约翰的游戏John

2016-01-06 21:41 344 查看
/article/2649718.html

#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<iostream>

using namespace std;

void setIO(const string& s) {
freopen((s + ".in").c_str(), "r", stdin);
freopen((s + ".out").c_str(), "w", stdout);
}
template<typename Q> Q read(Q& x) {
static char c, f;
for(f = 0; c = getchar(), !isdigit(c); ) if(c == '-') f = 1;
for(x = 0; isdigit(c); c = getchar()) x = x * 10 + c - '0';
if(f) x = -x;
return x;
}
template<typename Q> Q read() {
static Q x; read(x); return x;
}

int main() {
#ifdef DEBUG
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
#endif

int T = read<int>(), x, n, xor_sum, flag;
while(T--) {
read(n);
xor_sum = 0; flag = 1;
while(n--) {
read(x);
if(x ^ 1) flag = 0;
xor_sum ^= x;
}

puts((flag ^ (bool)xor_sum) ? "John" : "Brother");
}

return 0;
}


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: