标签:stack break span log algorithm 斐波那契 ret output link
题解:
吧斐波那契数组处理出来
就是这题了:这题
#include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include <algorithm> using namespace std; #pragma comment(linker, "/STACK:102400000,102400000") #define ls i<<1 #define rs ls | 1 #define mid ((ll+rr)>>1) #define pii pair<int,int> #define MP make_pair typedef long long LL; const long long INF = 1e18+1LL; const double Pi = acos(-1.0); const int N = 5e5+10, M = 2e5+20, mod = 1e9+7, inf = 2e9; int f[N],n,m,p,sg[N],vis[N]; int main() { f[1] = 1; f[2] = 2; int cnt = 2; for(int i = 3; ; ++i,++cnt) { f[i] = f[i-1] + f[i-2]; if(f[i] > 1000) break; } sg[0] = 0; for(int i = 1; i <= 1000; ++i) { for(int j = 1; j <= cnt; ++j) { if(f[j] > i) break; vis[sg[i - f[j]]] = 1; } for(int j = 0; j <= 100; ++j) if(!vis[j]){ sg[i] = j;break;} for(int j = 1; j <= cnt; ++j) { if(f[j] > i) break; vis[sg[i - f[j]]] = 0; } } while(scanf("%d%d%d",&n,&m,&p) && n &&m && p) { if(sg[n] ^ sg[m] ^ sg[p]) { puts("Fibo"); }else puts("Nacci"); } return 0; }
标签:stack break span log algorithm 斐波那契 ret output link
原文地址:http://www.cnblogs.com/zxhl/p/6011167.html