SG函数 模板
1 int get_SG(int x) 2 { 3 if (SG[x]!=-1) 4 return SG[x]; 5 bool v[110]={0}; 6 for (int i=1;i<=n;i++) 7 if (x-s[i]>=0) 8 v[get_SG(x-s[i])]=1; 9 int i; 10 for (i=0;v[i];i++); 11 SG[x]=i; 12 return i; 13 }
Every day is meaningful, keeping learning!