[BZOJ1022]SHOI2008 JONH|anti-Nim|SG函数

来源:互联网 发布:json的类子 编辑:程序博客网 时间:2024/06/08 07:42

妈呀博弈论。。看了好久才看懂。。我觉得我讲不清,自行学习SG函数和nim游戏。。组合游戏略述——浅谈SG游戏的若干拓展及变形

#include<iostream>#include<cstdio>using namespace std;int T,i,q,sg,n;bool f;int main(){scanf("%d",&T);while (T--){f=false;sg=0;scanf("%d",&n);for (i=1;i<=n;i++) {scanf("%d",&q);if (q>1) f=true;sg^=q;}if ((!f&&!sg)||(f&&sg)) printf("John\n"); else printf("Brother\n");}}


0 0