#C10521. Guess the Hidden Number

    ID: 39736 Type: Default 1000ms 256MiB

Guess the Hidden Number

Guess the Hidden Number

You are required to guess a hidden number N such that \(1 \le N \le 10^9\). You have at most 20 attempts.

After each guess, you will receive one of three responses:

  • TOO HIGH: Your guess is greater than \(N\).
  • TOO LOW: Your guess is less than \(N\).
  • CORRECT: Your guess is exactly \(N\).

Implement an efficient guessing strategy (hint: binary search) to determine \(N\) within the allowed number of attempts. The program should terminate immediately upon receiving the "CORRECT" response or after 20 attempts.

inputFormat

The input consists of a series of responses from the system via standard input. Each response is one of "TOO HIGH", "TOO LOW", or "CORRECT". In an interactive setup, after outputting a guess, the program reads a line from standard input containing the system's feedback.

outputFormat

The program should output each integer guess on a separate line to standard output. The guessing continues until the system responds with "CORRECT" or 20 attempts have been made.## sample

CORRECT
500000000

</p>