打表博弈也没什么好说的,其实比赛时想到了,但是错误认为两个数异或不会得到一个更大的数就没打表,,,还是太菜了,,,
附打表代码
#include <bits/stdc++.h> using namespace std; int g[1010]; void init() { memset(g, -1, sizeof(g)); } int getSG(int x) { if(g[x] != -1) return g[x]; if(x == 0) return 0; if(x == 1) return 1; if(x == 2) return 2; int vis[110]; memset(vis, 0, sizeof(vis)); for(int i = 1; i < x; i++) { int t = 0; int a = getSG(i); t ^= a; for(int j = 1; j < x - i; j++) { int tt = t; int b = getSG(j); int c = getSG(x - i - j); tt ^= b; tt ^= c; vis[tt] = 1; vis[c] = vis[b] = 1; } vis[a] = 1; vis[t] = 1; } vis[0] = 1; for(int i = 0; ; i++) if(!vis[i]) return i; } int main() { int n; init(); for(int i = 1; i <= 100; i++) { g[i] = getSG(i); printf("%d %d %d ", i, i % 8, g[i]); } }