[2018.12.26]BZOJ1022 [SHOI2008]小约翰的游戏John

发现此题是Anti-Nim游戏。

实在太模板了,以至于我不必再写一次。

其实就是懒

之前接触博弈论比较少,以至于这是第一次接触此类问题。

code:

#include<bits/stdc++.h>
using namespace std;
int T,n,t,tg,ans;
int main(){
    scanf("%d",&T);
    while(T--){
        scanf("%d",&n);
        tg=ans=0;
        for(int i=1;i<=n;i++)scanf("%d",&t),ans^=t,tg|=(t!=1);
        cout<<(tg?(ans?"John\n":"Brother\n"):((n&1)?"Brother\n":"John\n"));
    }
    return 0;
}
posted @ 2019-03-15 15:37  xryjr233  阅读(91)  评论(0编辑  收藏  举报