bzoj1022: [SHOI2008]小約翰的遊戲John
阿新 • • 發佈:2019-02-27
color nbsp 一個 span clas als cst ring mes
反nim遊戲
性質:1、遊戲的SG值為0且所有子遊戲SG值均不超過1。 2、遊戲的SG值不為0且至少一個子遊戲SG值超過1。先手必勝
#include<cstdio> #include<cstring> using namespace std; int main() { int T; scanf("%d",&T); while(T--) { int n,ss=0,x;bool bk=false; scanf("%d",&n); for(int i=1;i<=n;i++) { scanf("%d",&x); if(x>1)bk=true; ss^=x; } if(bk==false&&n%2==1)printf("Brother\n"); else if(bk==false&&n%2==0)printf("John\n"); else if(ss>0)printf("John\n"); else printf("Brother\n"); } return 0; }
bzoj1022: [SHOI2008]小約翰的遊戲John