No.1793 Real Number Guessing Game
This problem is the December 22 problem of yukicoder Advent Calendar Contest 2021.
Problem Statement
This is an interactive problem.
In this problem, each input contains $T$ test cases.
A loves a certain real number $x$ between $0$ and $12.22\times 10^{74}$, inclusive.
Guess A's favorite real number $x$ by asking the following question.
- Is the real number $y$ less than or equal to $x$?
However, A is busy and will answer at most $24$ questions.
But A is kind, and will accept your answer as correct if its absolute error or relative error is at most $10^{-5}$.
▶What are absolute error and relative error?
- Absolute error: for a true value $x$, the absolute error of $y$ is defined as $\displaystyle|x-y|$.
- Relative error: for a true value $x\ (\neq 0)$, the relative error of $y$ is defined as $\displaystyle\frac{|x-y|}{|x|}$.
Input and Output
First, the number of test cases $T$ is given.
$T$
$T$ is an integer satisfying $1\le T \le 100$.
Then, $T$ test cases follow.
Print each question to standard output in the following format.
? $y$
Here, $0\le y\le 12.22\times 10^{74}$ must be satisfied.
The response to a question is given from standard input in the following format.
$S$
Here, $S$ is one of the following strings.
Yes: the real number $y$ is less than or equal to $x$.No: the real number $y$ is not less than or equal to $x$.-1: the number of questions exceeded $24$, or you produced invalid output. In this case, terminate your program immediately.
When answering with the real number $x$, print it to standard output in the following format.
! $x$
Here, $0\le x\le 12.22\times 10^{74}$ must be satisfied.
Your answer is treated as correct if its absolute error or relative error is at most $10^{-5}$.
After that, continue with the next test case if there is one; otherwise, terminate your program immediately.
End each output with a newline and flush standard output.
Constraints
$1\le T\le 100$
$0\le x\le 12.22\times 10^{74}$
Sample
For $T=2$, the following interaction is possible.
| Input | Output | Explanation |
|---|---|---|
| 2 | $T=2$ | |
| ? 1 | Start of the first test case | |
| No | $1$ is not less than or equal to $x$ | |
| ? 0.99999999 | ||
| Yes | $0.99999999$ is less than or equal to $x$ | |
| ! 0.99999999 | ||
| ? 1.41421356 | Start of the second test case | |
| Yes | $1.41421356$ is less than or equal to $x$ | |
| ! 3.14159265 |
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
とりゐ