标签:++ mil == java get title 输出 vector hdoj
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 9296 Accepted Submission(s): 3893
#include <iostream> #include <algorithm> #include <cstring> #include <cstdio> #include <vector> #include <queue> #include <cstdlib> #include <iomanip> #include <cmath> #include <cassert> #include <ctime> #include <map> #include <set> using namespace std; #define lowbit(x) (x&(-x)) #define max(x,y) (x>y?x:y) #define min(x,y) (x<y?x:y) #define MAX 100000000000000000 #define MOD 1000000007 #define pi acos(-1.0) #define ei exp(1) #define PI 3.141592653589793238462 #define ios() ios::sync_with_stdio(false) #define INF 1044266558 #define mem(a) (memset(a,0,sizeof(a))) typedef long long ll; int fib[20],n,m,q; int sg[1005]; bool vis[1005]; void init() { memset(fib,0,sizeof(fib)); fib[0]=1;fib[1]=2; for(int i=2;i<=15;i++) { fib[i]=fib[i-1]+fib[i-2]; } } void get_sg() { init(); int i,j; memset(sg,0,sizeof(0)); for(i=0;i<=1000;i++) { memset(vis,0,sizeof(vis)); for(j=0;fib[j]<=i;j++) { if(i-fib[j]>=0) vis[sg[i-fib[j]]]=1; } for(j=0;j<=1000;j++) if(!vis[j]) break; sg[i]=j; } } int main() { get_sg(); while(scanf("%d%d%d",&n,&m,&q)&& (n && m && q)) { puts((sg[n]^sg[m]^sg[q])==0?"Nacci":"Fibo"); } return 0; }
博弈论 SG函数(模板) HDU 1848 Fibonacci again and again
标签:++ mil == java get title 输出 vector hdoj
原文地址:http://www.cnblogs.com/shinianhuanniyijuhaojiubujian/p/7346029.html