Game theory
A look at the question, wow this is not nim game = = directly different or up ... Ah, what's wrong?
This problem is "Anti-nim", the common Nim is to take the last one to win, the problem is to take the last one to lose ...
Procedure See 2009 Jia Zhihao paper "Combinatorial Game"--on the development and transformation of SG game
1 /**************************************************************2 problem:10223 User:tunix4 language:c++5 result:accepted6 time:16 Ms7 memory:1272 KB8 ****************************************************************/9 Ten //Bzoj 1022 One#include <cstdio> A#include <iostream> - #defineF (i,j,n) for (int i=j;i<=n;++i) - using namespacestd; the - intGetint () { - intv=0, r=1;CharCh=GetChar (); - for(;! IsDigit (CH); Ch=getchar ())if(ch=='-') r=-1; + for(; isdigit (ch); Ch=getchar ()) v=v*Ten+ch-'0'; - returnv*R; + } A /*******************template********************/ at - intMain () { - intt=getint (); - while(t--){ - intN=getint (), x=0, y=0; - BOOLsign=1; inF (I,1, N) { -y=getint (); tox^=y; + if(y>1) sign=0; - } the if(sign &&!x) | | (!sign && x)) Puts"John"); * ElsePuts"Brother"); $ }Panax Notoginseng return 0; -}
View Code
"Bzoj" "1022" "SHOI2008" Little John's game John