LuoguP4279 [SHOI2008]小约翰的游戏

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\n");
        else if(sum&&flag) printf("John\n");
        else printf("Brother\n");
    }
    return 0;
} 

 

posted @ 2020-07-16 19:19  wlzs1432  阅读(98)  评论(0编辑  收藏  举报