Problem Description
1堆石子有n个,两人轮流取.先取者第1次可以取任意多个,但不能全部取完.以后每次取的石子数不能超过上次取子数的2倍。取完者胜.先取者负输出"Second win".先取者胜输出"First win".
Input
输入有多组.每组第1行是2<=n<2^31. n=0退出.
Output
先取者负输出"Second win". 先取者胜输出"First win".
参看Sample Output.
参看Sample Output.
Sample Input
2
13
10000
0
Sample Output
Second win
Second win
First win
/* *********************************************** Author :devil Created Time :2016/5/26 23:3:14 ************************************************ */ #include <cstdio> #include <cstring> #include <iostream> #include <algorithm> #include <vector> #include <queue> #include <set> #include <assert.h> #include <map> #include <string> #include <cmath> #include <stdlib.h> using namespace std; int f[60]; int main() { //freopen("in.txt","r",stdin); int n; f[0]=1; f[1]=1; for(int i=2;i<60;i++) f[i]=f[i-1]+f[i-2]; while(~scanf("%d",&n)&&n) { bool flag=0; for(int i=0;i<60;i++) if(n==f[i]) { flag=1; break; } if(flag) printf("Second win "); else printf("First win "); } return 0; }