Hdu2516 stone game ----- regular searching

Source: Internet
Author: User

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
*/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.