CSES - Hidden Integer
  • Time limit: 1.00 s
  • Memory limit: 512 MB

There is a hidden integer xx. Your task is to find the value of xx.

To do this, you can ask questions: you can choose an integer yy and you will be told if y<xy < x.

Interaction

This is an interactive problem. Your code will interact with the grader using standard input and output. You can start asking questions right away.

On your turn, you can print one of the following:

  • "? y?\ y", where 1y1091 \le y \le 10^9: ask if y<xy < x. The grader will return YES if y<xy < x and NO otherwise.
  • "! x!\ x": report that the hidden integer is xx. Your program must terminate after this.

Each line should be followed by a line break. You must make sure the output gets flushed after printing each line.

Constraints

  • 1x1091 \le x \le 10^9
  • you can ask at most 3030 questions of type ??

Example

? 3
YES
? 6
YES
? 7
NO
! 7