hdu2516

hdu2516
斐波那契博弈,也是一堆博弈的一种,第一个人第一次可以拿任意多,但是不能取完,第二个人拿至少一个,但不能超过上一个人拿的两倍

#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<stack>
#include<cstring>
#define inf 2147483647
#define ls rt<<1
#define rs rt<<1|1
#define lson ls,nl,mid,l,r
#define rson rs,mid+1,nr,l,r
#define N 100010
#define For(i,a,b) for(long long i=a;i<=b;i++)
#define p(a) putchar(a)
#define g() getchar()

using namespace std;
long long f[100],n;
void in(long long &x){
    long long y=1;
    char c=g();x=0;
    while(c<'0'||c>'9'){
        if(c=='-')y=-1;
        c=g();
    }
    while(c<='9'&&c>='0'){
        x=(x<<1)+(x<<3)+c-'0';c=g();
    }
    x*=y;
}
void o(long long x){
    if(x<0){
        p('-');
        x=-x;
    }
    if(x>9)o(x/10);
    p(x%10+'0');
}
int main(){
    f[0]=f[1]=1;
    For(i,2,50)
        f[i]=f[i-1]+f[i-2];
    
    while(cin>>n&&n){
        if(binary_search(f+1,f+51,n))
            puts("Second win");
        else
            puts("First win");
    }
    return 0;
}
原文地址:https://www.cnblogs.com/war1111/p/11225977.html