Nimes Game is a simple function of the reflected sg
Learning crude: https: //blog.csdn.net/luomingjun12315/article/details/45555495
// f [N]: may change the way the current state, N being a mode type, f [N] to be pretreated prior getSG // SG []: 0 ~ SG function of the value of n // S []: x is the set of successor states int F [N], SG [MAXN], S [MAXN]; void getSG (n-int) { int I, J; Memset (SG, 0, the sizeof (SG)); // since SG [0] is always equal to 0, so i runs from the start. 1 for (i =. 1; i <= n-; i ++) { // each subsequent time must be set on a reset state memset (S, 0, sizeof ( S )); for (J = 0; F [J] <= I && J <= N; J ++) S [SG [IF [J]]] =. 1; // the SG function value successor states is labeled for ( ! j = 0 ;; j ++) if (S [j]) {// check the current values of the successor state SG smallest non-zero value SG [I] = J; BREAK; } } }