标签:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 8634 Accepted Submission(s): 5587
#include <iostream> #include <cstring> #include <stdio.h> #include <stdlib.h> #include <algorithm> #include <map> using namespace std; const int N = 1005; int sg[N]; bool Hash[N]; void sg_solve(int *s,int t,int N) ///N求解范围 S[]数组是可以每次取的值,t是s的长度。 { int i,j; memset(sg,0,sizeof(sg)); for(i=1; i<=N; i++) { memset(Hash,0,sizeof(Hash)); for(j=0; j<t; j++) if(i - s[j] >= 0) Hash[sg[i-s[j]]] = 1; for(j=0; j<=N; j++) if(!Hash[j]) break; sg[i] = j; } } int main() { int s[15]; for(int i=0;i<=9;i++) s[i] = (1<<i); ///每次可取 1 2 4 8 16 32 64 128 256 512 sg_solve(s,10,N); int n; while(scanf("%d",&n)!=EOF){ if(sg[n]){ printf("Kiki\n"); }else{ printf("Cici\n"); } } return 0; }
标签:
原文地址:http://www.cnblogs.com/liyinggang/p/5768660.html