Reprint Please specify source: http://blog.csdn.net/vmurder/article/details/42653601
In fact, I just feel that the original traffic is a bit more uncomfortable than unauthorized piracy 233 ...
Test instructions
The two took turns to fetch k stones from some heap of stones,
K∈ set S, that is, the number of each fetch is limited to a number of the meaning!
Then, as with normal Nim , no one can operate and lose.
Exercises
The SG function naked question.
SG function:
The first step is to have a direction-free graph (topology map)
The boundary state is determined first, the SG value is 0, and then the violent topology draws the SG value of the other points.
The SG value is the minimum natural number that does not appear in the SG value for all subsets.
Sg==0 is negative.
The SG function satisfies all games (the starting state) of the SG xor up to 0 minus, or 1 wins.
If you are the same as me Konjac Konjac, do not want to prove that it is right, write on the line, otherwise it is over and over again decadent give up wasting time.
Code (look at a similar strip Code also line):
#include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #define N 105# Define M 10100using namespace Std;int s,s[n];int sg[m];int sg (int x) {int i;if (sg[x]+1) return Sg[x];bool vis[m<<1]={ 0};for (i=1;i<=s;i++) if (s[i]<=x) VIS[SG (X-s[i])]=true;for (i=0;vis[i];i++); return sg[x]=i;} int N,m;int Main () {//freopen ("test.in", "R", stdin); int I,k,g;while (scanf ("%d", &s), S)//Data group A{for (i=1;i<=s;i+ +) scanf ("%d", &s[i]); Sort (s+1,s+s+1);//s: Aggregates memset (sg,-1,sizeof (SG)), Sg[0]=0;for (scanf ("%d", &g), g--;)//Data group B{for (k=0 , scanf ("%d", &n), n--;)//n heap of Stones {scanf ("%d", &m);//The number of stones in the heap k^=sg (m);} if (k) Putchar (' W '); else Putchar (' L ');} Puts ("");} return 0;}
"POJ2960" S-nim SG function Game template problem with naked title