AtCoder Regular Contest 078
E
Awkward Response
AtCoder
⌀ 2300
原题
←F →
翻译中…

Problem Statement

翻译中…

This is an interactive task.

翻译中…

Snuke has a favorite positive integer, $N$. You can ask him the following type of question at most $64$ times: "Is $n$ your favorite integer?" Identify $N$.

翻译中…

Snuke is twisted, and when asked "Is $n$ your favorite integer?", he answers "Yes" if one of the two conditions below is satisfied, and answers "No" otherwise:

翻译中…
  • Both $n \leq N$ and $str(n) \leq str(N)$ hold.
  • Both $n > N$ and $str(n) > str(N)$ hold.
翻译中…

Here, $str(x)$ is the decimal representation of $x$ (without leading zeros) as a string. For example, $str(123) =$ 123 and $str(2000)$ = 2000. Strings are compared lexicographically. For example, 11111 $<$ 123 and 123456789 $<$ 9.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 10^{9}$
翻译中…

Input and Output

翻译中…

Write your question to Standard Output in the following format:

翻译中…

? n

翻译中…

Here, $n$ must be an integer between $1$ and $10^{18}$ (inclusive).

翻译中…

Then, the response to the question shall be given from Standard Input in the following format:

翻译中…

ans

翻译中…

Here, $ans$ is either Y or N. Y represents "Yes"; N represents "No".

翻译中…

Finally, write your answer in the following format:

翻译中…

! n

翻译中…

Here, $n=N$ must hold.

翻译中…

Judging

翻译中…
  • After each output, you must flush Standard Output. Otherwise you may get TLE.
  • After you print the answer, the program must be terminated immediately. Otherwise, the behavior of the judge is undefined.
  • When your output is invalid or incorrect, the behavior of the judge is undefined (it does not necessarily give WA).
翻译中…

Sample

翻译中…

Below is a sample communication for the case $N=123$:

翻译中…
Input Output
? 1
Y
? 32
N
? 1010
N
? 999
Y
! 123
翻译中…
  • Since $1 \leq 123$ and $str(1) \leq str(123)$, the first response is "Yes".
  • Since $32 \leq 123$ but $str(32) > str(123)$, the second response is "No".
  • Since $1010 > 123$ but $str(1010) \leq str(123)$, the third response is "No".
  • Since $999 \geq 123$ and $str(999) > str(123)$, the fourth response is "Yes".
  • The program successfully identifies $N=123$ in four questions, and thus passes the case.
翻译中…
题目信息
题号
arc078_c
时间限制
2 s
内存限制
256 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。