BZOJ 1022: [SHOI2008]小约翰的游戏John

二次联通门 : BZOJ 1022: [SHOI2008]小约翰的游戏John

 

 

 

 

/*

    BZOJ 1022: [SHOI2008]小约翰的游戏John


    博弈论

    lqz 这种zz怎么可能会博弈呢?

    
*/
#include <cstdio>
#include <iostream>

#define rg register
inline void read (int &n)
{
    rg char c = getchar ();
    for (n = 0; !isdigit (c); c = getchar ());
    for (; isdigit (c); n = n * 10 + c - '0', c = getchar ());
}

int main (int argc, char *argv[])
{
    int T, N, x, sg; bool f; rg int i;
    read (T);
    for (; T; -- T)
    {
        read (N); f = false, sg = 0;
        for (i = 1; i <= N; ++ i)
        {
            read (x);
            if (x != 1) f = true;
            sg ^= x;
        }
        if ((!f && !sg) || (sg && f)) puts ("John");
        else puts ("Brother");
    }    

    return 0;
}

 

posted @ 2017-12-27 21:12  ZlycerQan  阅读(58)  评论(0编辑  收藏