Stone game
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission (s): 1394 Accepted Submission (s): 780
Problem Description
There are n stones in one heap, and the two take turns. the first accessors can fetch any number of entries for 1st times, but not all of them. in the future, the number of stones retrieved each time cannot exceed 2 times the number of stones obtained last time. The winner wins. The First winner outputs "Second win". The First winner wins the output "First win ".
Input
There are multiple groups of input. Each group has 2 rows <= n <2 ^ 31. n = 0 to exit.
Output
The First accessor outputs "Second win". The First accessors win the output "First win ".
See Sample Output.
Sample Input
2
13
10000
0
Sample Output
Second win
Second win
First win
Source
Ecjtu2008 Autumn Contest
Recommend
Lcy
The point of defeat is the Fibonacci series.
[Cpp]
# Include <iostream>
# Include <cstdlib>
# Include <stdio. h>
Using namespace std;
# Define ll _ int64
Ll f [45];
Int main ()
{
F [0] = 2; f [1] = 3;
For (int I = 2; I <= 44; I ++)
F [I] = f [I-1] + f [I-2];
Ll n;
While (scanf ("% I64d", & n)
{
Int I;
For (I = 0; I <= 44; I ++)
{
If (f [I] = n)
Break;
}
If (I <44) puts ("Second win ");
Else puts ("First win ");
}
}
/*
Sample Input
2
13
10000
0
Sample Output
Second win
Second win
First win
*/