Game theory
At first I wanted to be a s-nim ... Later found not the same = = the stone is to be taken, but the stripe is like crosses and crosses, it can be spread to the middle, left and right to leave the gap but the opponent has nowhere to put ...
So that is the two-way combination of the method of the ~
1 /**************************************************************2 problem:29403 User:tunix4 language:c++5 result:accepted6 time:60 Ms7 memory:1276 KB8 ****************************************************************/9 Ten //Bzoj 2940 One#include <cstdio> A#include <cstring> -#include <iostream> - #defineF (i,j,n) for (int i=j;i<=n;++i) the intGetint () { - intv=0, sign=1;CharCh=GetChar (); - while(!isdigit (CH)) {if(ch=='-') sign=-1; Ch=GetChar ();} - while(IsDigit (CH)) {v=v*Ten+ch-'0'; Ch=GetChar ();} + returnv*Sign ; - } + Const intn=1010, inf=~0u>>2; A at inta[4],sg[n]; - BOOLMark[n]; - intMain () { -F (I,1,3) a[i]=getint (); - intn=getint (); -F (I,1, +){ inmemset (Mark,0,sizeofmark); -F (J,1,3) to for(intk=0; k<=i-a[j]-k;++k) +mark[sg[k]^sg[i-a[j]-k]]=1; -F (J,0Iif(!mark[j]) {sg[i]=j; Break;} the } *F (I,1, N) { $printf"%d", Sg[getint ()]?1:2);Panax Notoginseng if(i!=n) printf ("\ n"); - } the return 0; +}View Code
"Bzoj" "2940" "POI2000" stripe