Game theory
That's like Bzoj 1874 for a pebble game.
First burst of the SG function within 10000 (using the definition to find out)
Then each query directly to the SG value can be different or up ...
1 Source Code2Problem:2960user:sdfzyhy3 memory:444k time:313ms4language:g++result:accepted5 6 Source Code7 8 //POJ 29609#include <cstdio>Ten#include <cstring> One #defineF (i,j,n) for (int i=j;i<=n;++i) A intGetint () { - intv=0, sign=1;CharCh=GetChar (); - while(ch<'0'|| Ch>'9'){if(ch=='-') sign=-1; Ch=GetChar ();} the while(ch>='0'&&ch<='9') {v=v*Ten+ch-'0'; Ch=GetChar ();} - returnv*=Sign ; - } - Const intn=10010; + /******************tamplate*********************/ - intf[n],s[101]; + BOOLMark[n]; A voidCALSG (intN) { atf[0]=0; -F (I,1,10000){ -memset (Mark,0,sizeofmark); -F (J,1, N)if(i-s[j]>=0) -mark[f[i-s[j]]]=1; -F (J,0Iif(!mark[j]) {f[i]=j; Break;} in } - } to intMain () { + intn,m,k; - while(SCANF ("%d", &n)!=eof &&N) { theF (I,1, N) s[i]=getint (); *m=getint (); $ CALSG (n);Panax NotoginsengF (I,1, M) { -k=getint (); the intans=0; +F (J,1, k) ans^=F[getint ()]; Aprintf (ans?)"W":"L"); the } +printf"\ n"); - } $ return 0; $}View Code
"POJ" "2960" S-nim