G1. Ruler (easy version)
binary search; interactive
This is the easy version of the problem. The only difference between the two versions is that in this version, you can make at most \(\mathbf{10}\) queries.This is an interactive problem. If you are unsure how interactive problems work, then it is recommended to read the guide for participants.We have a secret ruler that is missing one number \(x\) (\(2 \leq x \leq 999\)). When you measure an object of length \(y\), the ruler reports the following values: If \(y < x\), the ruler (correctly) measures the object as having length \(y\). If \(y \geq x\), the ruler incorrectly measures the object as having length \(y+1\). The ruler above is missing the number \(4\), so it correctly measures the first segment as length \(3\) but incorrectly measures the second segment as length \(6\) even though it is actually \(5\). You need to find the value of \(x\). To do that, you can make queries of the following form: \(\texttt{?}~a~b\) — in response, we will measure the side lengths of an \(a \times b\) rectangle with our ruler and multiply the results, reporting the measured area of the rectangle back to you. For example, if \(x=4\) and you query a \(3 \times 5\) rectangle, we will measure its side lengths as \(3 \times 6\) and report \(18\) back to you. Find the value of \(x\). You can ask at most \(\mathbf{10}\) queries.
Each test contains multiple test cases. The first line of input contains a single integer \(t\) (\(1 \leq t \leq 1000\)) — the number of test cases.
In the first test, the interaction proceeds as follows. SolutionJuryExplanation\(\texttt{2}\)There are 2 test cases.\(\texttt{? 3 5}\)\(\texttt{18}\)Secretly, the jury picked \(x=4\). The solution requests the \(3 \times 5\) rectangle, and the jury responds with \(3 \times 6 = 18\), as described in the statement.\(\texttt{? 4 4}\)\(\texttt{25}\)The solution requests the \(4 \times 4\) rectangle, which the jury measures as \(5 \times 5\) and responds with \(25\).\(\texttt{! 4}\)The solution has somehow determined that \(x=4\), and outputs it. Since the output is correct, the jury continues to the next test case.\(\texttt{? 99 100}\)\(\texttt{1}\)Secretly, the jury picked \(x=100\). The solution requests the \(99 \times 100\) rectangle, which the jury measures as \(99 \times 101\) and responds with \(9999\).\(\texttt{! 100}\)The solution has somehow determined that \(x=100\), and outputs it. Since the output is correct and there are no more test cases, the jury and the solution exit. Note that the line breaks in the example input and output are for the sake of clarity, and do not occur in the real interaction.