TLE '17 Contest 5 P1 - Guess the Number

View as PDF

Submit solution


Points: 3 (partial)
Time limit: 2.0s
Memory limit: 256M

Author:
Problem type
Fax and Flaco are playing Guess the Number.

Fax McClad, Croneria's luckiest bounty hunter, is playing a guessing game with Flaco.

Flaco chooses an integer N between -50 and 50, inclusive. Then, Fax will repeatedly make guesses until he is certain what N is.

Suppose Fax guesses n. Then, Flaco will tell him that he is |N-n| 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 -50 and 50, inclusive. Then your program should read in an integer, which is the value of |N-n|.

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 0 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 5 guesses were made. That is, answer does not count as a guess.


Comments

There are no comments at the moment.