标签:nbsp hdu1848 http hdu == include target span stream
题目连接:HDU - 1848
1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 #include<iostream> 5 using namespace std; 6 const int maxn=1010; 7 const int M=25; 8 int fib[M]; 9 int sg[maxn]; 10 int mex(int x) 11 { 12 int vis[M]; 13 memset(vis,0,sizeof(vis)); 14 for(int i=0;i<M;i++) 15 { 16 int t=x-fib[i]; 17 if(t<0) break; 18 if(sg[t]==-1) sg[t]=mex(t); 19 vis[sg[t]]=1; 20 } 21 for(int i=0;;i++) 22 if(!vis[i]) return i; 23 } 24 void init() 25 { 26 fib[0]=1; 27 fib[1]=2; 28 for(int i=2;i<M;i++) 29 fib[i]=fib[i-1]+fib[i-2]; 30 memset(sg,-1,sizeof(sg)); 31 for(int i=0;i<maxn;i++) 32 sg[i]=mex(i); 33 } 34 int main() 35 { 36 init(); 37 int a,b,c; 38 while(scanf("%d%d%d",&a,&b,&c)!=EOF) 39 { 40 if(a==0&&b==0&&c==0) break; 41 int ans=0; 42 ans^=sg[a]; 43 ans^=sg[b]; 44 ans^=sg[c]; 45 if(ans) puts("Fibo"); 46 else puts("Nacci"); 47 } 48 }
标签:nbsp hdu1848 http hdu == include target span stream
原文地址:http://www.cnblogs.com/yijiull/p/6803188.html