码迷,mamicode.com
首页 > 其他好文 > 详细

LuoguP4279 [SHOI2008]小约翰的游戏

时间:2020-07-16 21:44:29      阅读:72      评论:0      收藏:0      [点我收藏+]

标签:lin   for   bool   http   flag   ++   lag   style   its   

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;
} 

 

LuoguP4279 [SHOI2008]小约翰的游戏

标签:lin   for   bool   http   flag   ++   lag   style   its   

原文地址:https://www.cnblogs.com/wlzs1432/p/13324501.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!