[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
":"Brother
"):((n&1)?"Brother
":"John
"));
    }
    return 0;
}
原文地址:https://www.cnblogs.com/xryjr233/p/BZOJ1022.html