Score : $800$ points
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:
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
.
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.
TLE
.WA
).Below is a sample communication for the case $N=123$:
Input | Output |
---|---|
? 1 |
|
Y |
|
? 32 |
|
N |
|
? 1010 |
|
N |
|
? 999 |
|
Y |
|
! 123 |