先上题目:
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4964 Accepted Submission(s): 2072
1 #include <iostream> 2 #include <cstring> 3 #define MAX 1100 4 using namespace std; 5 6 int fb[MAX],sg[MAX],all; 7 bool f[MAX]; 8 9 int main() 10 { 11 int n,m,p; 12 ios::sync_with_stdio(false); 13 fb[0]=1; fb[1]=2; 14 for(int all=2;fb[all-1]+fb[all-2]<=2000;all++){ 15 fb[all]=fb[all-1]+fb[all-2]; 16 } 17 sg[0]=0; 18 for(int i=1;i<=1000;i++){ 19 memset(f,0,sizeof(f)); 20 for(int j=0;fb[j]<=i;j++){ 21 f[sg[i-fb[j]]]=1; 22 } 23 for(int j=0;j<=i;j++){ 24 if(!f[j]){ 25 sg[i]=j; 26 break; 27 } 28 } 29 } 30 while(cin>>n>>m>>p,(n+m+p)){ 31 if(sg[n]^sg[m]^sg[p]) cout<<"Fibo"<<endl; 32 else cout<<"Nacci"<<endl; 33 } 34 return 0; 35 }
HDU - 1848 - Fibonacci again and again,布布扣,bubuko.com
HDU - 1848 - Fibonacci again and again
原文:http://www.cnblogs.com/sineatos/p/3887549.html