分析
可取状态只能是斐波那契数,求出SG函数
然后判断三个数sg函数异或和不为0先手必胜
代码
#include <cstdio>
#include <cctype>
#define rr register
using namespace std;
const int p[15]={1,2,3,5,8,13,21,34,55,89,144,233,377,610,987};
const int N=1011; int sg[N],v[N];
inline signed iut(){
rr int ans=0; rr char c=getchar();
while (!isdigit(c)) c=getchar();
while (isdigit(c)) ans=(ans<<3)+(ans<<1)+(c^48),c=getchar();
return ans;
}
signed main(){
for (rr int i=1;i<N;++i){
for (rr int j=0;j<15&&p[j]<=i;++j)
v[sg[i-p[j]]]=1;
for (;v[sg[i]];++sg[i]);
for (rr int j=0;j<15&&p[j]<=i;++j)
v[sg[i-p[j]]]=0;
}
while (1){
rr int n=iut(),m=iut(),k=iut();
if (!n&&!m&&!k) break;
if (sg[n]^sg[m]^sg[k]) puts("Fibo");
else puts("Nacci");
}
return 0;
}