영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
시간 제한 1초 · 메모리 제한 512 MB
Problem
There is a hidden integer x. Your task is to find the value of x.
To do this, you can ask questions: you can choose an integer y and you will be told if y < 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", where 1 ≤ y ≤ 10^9: ask if y < x. The grader will return
YESif y < x andNOotherwise. - "! x": report that the hidden integer is x. 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
- 1 ≤ x ≤ 10^9
- you can ask at most 30 questions of type ?
Example
? 3
YES
? 6
YES
? 7
NO
! 7