题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1848
#include <stdio.h>
#include <string.h>
#define MAXN 1002
int sg[MAXN],hash[MAXN];
int fib[15]={1,2,3,5,8,13,21,34,55,89,144,233,377,610,987};
void getSG(int n)
{
int i,j;
memset(sg,0,sizeof(sg));
for(i=1;i<=n;++i)
{
memset(hash,0,sizeof(hash));
for(j=0;j<15;++j)
{
if(i<fib[j])
break;
hash[sg[i-fib[j]]]=1;
}
for(j=0;j<15;++j)
{
if(!hash[j])
{
sg[i]=j;
break;
}
}
}
}
int main()
{
int n,m,p,ans;
getSG(1000);
while (scanf("%d %d %d",&m,&n,&p))
{
if(m+n+p==0)
break;
ans=0;
ans^=sg[m]^sg[n]^sg[p];
if(ans)
printf("Fibo\n");
else
printf("Nacci\n");
}
return 0;
}