https://scut.online/p/93
each stone is taken away the power of b. Violence hit the table.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1000005;
//f[i]:可改变i状态的方式
//SG[]:0~n的SG函数值
//S[]:为x后继状态的集合
vector<int> f[MAXN];
int SG[MAXN],S[MAXN];
void getSG(int n){
for(int i = 1; i <= n; i++){
int l=f[i].size();
//后继状态 最多有l 种
for(int j=0;j<=l;j++){
S[j]=0;
}
for(auto vi:f[i]){
//vi:从i状态能取走的石子数
S[SG[i-vi]]=1;
}
for(int j=0;j<=l;j++){
if(!S[j]){
SG[i] = j;
break;
}
}
cout<<"SG["<<i<<"]="<<SG[i]<<endl;
}
}
int N=120;
void enque(int id){
ll cur=1,b=8;
while(id>=cur){
f[id].push_back(cur);
cur*=b;
}
}
int main() {
#ifdef Yinku
freopen("Yinku.in", "r", stdin);
#endif // Yinku
for(int i=0;i<=N;i++){
enque(i);
}
getSG(N);
}