TLE '17 Contest 5 P1 - Guess the Number
View as PDF
Fax McClad, Croneria's luckiest bounty hunter, is playing a guessing game with Flaco.
Flaco chooses an integer  between 
 and 
, inclusive. Then, Fax will repeatedly make guesses until he is certain what 
 is.
Suppose Fax guesses . Then, Flaco will tell him that he is 
 away from the answer.
There are a lot of Moneys on the line, and the fewer the guesses Fax makes, the more Moneys he will win! Please help Fax to determine what Flaco's secret number is!
Interaction
This is an interactive problem.
Output guess n to guess a number n. This number should be between  and 
, inclusive. Then your program should read in an integer, which is the value of 
.
When you are sure about your answer, output answer n, where n is your answer, and terminate.
If your answer is wrong, you will receive  points. If your answer is correct, your score will depend on the number of guesses you made. The fewer the guesses, the higher your score.
Each time you output a number, make sure to output a new line \n and flush your output buffers. You can use fflush(stdout) in C++, System.out.flush(); in Java, or import sys; sys.stdout.flush() in Python 2/3. For other languages, search in its documentation.
Sample Interaction
>>> denotes your output; don't actually print this out.
>>> guess 5
5
>>> guess 3
7
>>> guess 14
4
>>> guess 10
0
>>> guess 11
1
>>> answer 10
Note that  guesses were made. That is, 
answer does not count as a guess.
Comments