标签:input out cout blog names while namespace rip end
#include <iostream> #include <cstring> #define ll long long using namespace std; int f[15]={1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987}; int sg[1005]; bool has[1005]; void getsg() { memset(sg,0,sizeof(sg)); for(int i=1;i<=1000;i++) { memset(has,false,sizeof(has)); for(int j=0;j<15;j++) { if(f[j]<=i) has[sg[i-f[j]]]=true; } for(int j=0;j<=1000;j++) { if(has[j]==false) { sg[i]=j; break; } } } } int main() { int n,m,p; getsg(); //cout<<"ll"<<endl; while(cin>>n>>m>>p) { if(n==0&&m==0&&p==0) break; int ans=0; ans=ans^sg[n]^sg[m]^sg[p]; if(ans) cout<<"Fibo"<<endl; else cout<<"Nacci"<<endl; } return 0; }
hdu 1848 Fibonacci again and again(简单sg)
标签:input out cout blog names while namespace rip end
原文地址:http://www.cnblogs.com/nefu929831238/p/6123655.html