LuoguP4279 [SHOI2008]小约翰的游戏
题目描述
Solution
Anti-SG的模板题
这里就直接放代码
#include<bits/stdc++.h> using namespace std; inline long long read() { long long f = 1 , x = 0; char ch; do { ch = getchar(); if(ch == '-') f = -1; }while(ch < '0' || ch > '9'); do { x = (x<<3) + (x<<1) + ch - '0'; ch = getchar(); }while(ch >= '0' && ch <= '9'); return f*x; } const int MAXN = 50 + 10; int T; int n; int a[MAXN]; int sum; int main() { T = read(); while(T--) { bool flag = 0; sum = 0; n = read(); for(register int i=1;i<=n;i++) { a[i] = read(); sum^=a[i]; if(a[i]>1) flag = 1; } if(!sum&&!flag) printf("John "); else if(sum&&flag) printf("John "); else printf("Brother "); } return 0; }