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

AC日记——[SHOI2008]小约翰的游戏John bzoj 1022

时间:2017-05-17 11:54:19      阅读:110      评论:0      收藏:0      [点我收藏+]

标签:logs   www   scanf   ref   problem   --   blog   nim   com   

1022

 

思路:

  nim;

 

代码:

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

using namespace std;

int main()
{
    int T;
    scanf("%d",&T);
    while (T--)
    {
        int n;
        scanf("%d",&n);
        int ans=0,pos;
        bool ok=true;
        while(n--)
        {
            scanf("%d",&pos),ans^=pos;
            if(pos!=1) ok=false;
        }
        if ((ok&&!ans)||(!ok&&ans)) printf("John\n");
        else printf("Brother\n");
    }
    return 0;
}

 

AC日记——[SHOI2008]小约翰的游戏John bzoj 1022

标签:logs   www   scanf   ref   problem   --   blog   nim   com   

原文地址:http://www.cnblogs.com/IUUUUUUUskyyy/p/6866109.html

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