HDU.2516 取石子游戏 (博弈论 斐波那契博弈)
题意分析
简单的斐波那契博弈
博弈论快速入门
代码总览
#include <bits/stdc++.h>
#define nmax 51
using namespace std;
int main()
{
int fib[nmax];
fib[1] = fib[2] = 1;
for(int i = 3;i<nmax;++i){
fib[i] = fib[i-1] + fib[i-2];
}
int n;
while(scanf("%d",&n) != EOF && n){
bool isfind = false;
for(int i = 1;i<nmax;++i){
if(n == fib[i]){
printf("Second win\n");
isfind = true;
break;
}
}
if(!isfind) printf("First win\n");
}
return 0;
}