题目描述
1堆石子有n个,两人轮流取.先取者第1次可以取任意多个,但不能全部取完.以后每次取的石子数不能超过上次取子数的2倍。取完者胜.先取者负输出"Second win".先取者胜输出"First win".
Input
输入有多组.每组第1行是2<=n<2^31. n=0退出.
Output
先取者负输出"Second win". 先取者胜输出"First win".
参看Sample Output.
Sample Input
2
13
10000
0
Sample Output
Second win
Second win
First win
题解
这题是典型的斐波那契博弈问题,这种题目我们只需要记住一个结论,如果这一堆的石子个数为斐波那契数,则先手必败,相反的先手必胜。
代码如下:
#include<cstdio>
#include<iostream>
#incl