【HDU】1848 Fibonacci again and again

时间:2022-08-22 11:29:56

http://acm.hdu.edu.cn/showproblem.php?pid=1848

题意:同nim,3堆,每次取的为fib数,n<=1000

#include <cstdio>
#include <cstring>
using namespace std;
int f[1005], a[100];
bool b[20];
int main() {
a[1]=1; a[2]=2;
for(int i=3; i<=15; ++i) a[i]=a[i-1]+a[i-2];
f[0]=0;
for(int i=1; i<=1000; ++i) {
memset(b, 0, sizeof b);
for(int j=1; j<=15; ++j) if(i>=a[j]) b[f[i-a[j]]]=1;
for(int j=0; j<=16; ++j) if(!b[j]) { f[i]=j; break; }
}
int x, y, z;
while(scanf("%d%d%d", &x, &y, &z), x|y|z) f[x]^f[y]^f[z]?puts("Fibo"):puts("Nacci");
return 0;
}

  


好无聊= =

求出sg然后求sg和就行了= =而且是暴力哦~