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

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

 

posted @ 2017-05-17 10:07  IIIIIIIIIU  阅读(138)  评论(0编辑  收藏  举报