作者:炙天痕_953 | 来源:互联网 | 2023-10-12 00:52
http://acm.hdu.edu.cn/showproblem.php?pid=1848
模拟sg
#include
using namespace std;
const int maxn = 1005;
int n,m,p;
int f[maxn],vis[maxn],sg[maxn];
void Init(){
f[1] = 1;
f[2] = 1;
for(int i = 3; i <= 1000; i++)
f[i] = f[i - 1] + f[i - 2];
sg[0] = 0;sg[1] = 1;
for(int i = 1; i <= 1000; i++){
memset(vis,0, sizeof(vis));
for(int j = 1; f[j] <= i; j++)
vis[sg[i - f[j]]] = 1;
for(int j = 0; j <= 1000;j++){
if(!vis[j]){
sg[i] = j;
break;
}
}
}
}
int main(){
//freopen("in","r",stdin);
ios::sync_with_stdio(0);
Init();
while(cin >> n >> m >> p){
if(!n && !m && !p) break;
if(sg[n] ^ sg[m] ^ sg[p])
cout <<"Fibo" << endl;
else cout <<"Nacci" << endl;
}
return 0;
}