标签:
/* *********************************************** Author :devil Created Time :2016/5/29 11:56:41 ************************************************ */ #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <assert.h> #include <map> #include <string> #include <cmath> #include <stdlib.h> using namespace std; const int N=1010; int sg[N],f[11]; bool vis[N]; void getsg(int n) { memset(sg,0,sizeof(sg)); for(int i=1;i<=n;i++) { memset(vis,0,sizeof(vis)); for(int j=0;f[j]<=i;j++) vis[sg[i-f[j]]]=1; for(int j=0;j<=n;j++) if(!vis[j]) { sg[i]=j; break; } } } int main() { //freopen("in.txt","r",stdin); int n; for(int i=0;i<=10;i++) f[i]=(1<<i); getsg(1000); while(~scanf("%d",&n)&&n) { if(sg[n]) printf("Kiki\n"); else printf("Cici\n"); } return 0; }
HDU1847 Good Luck in CET-4 Everybody!(SG函数)
标签:
原文地址:http://www.cnblogs.com/d-e-v-i-l/p/5539087.html