P4459 [BJOI2018] Two-Player Number Guessing Game
Background
This is an answer-submission problem. You can download the input file from "Attachment".
Description
Alice and Bob are very smart; they can figure out optimal strategies for all kinds of games. A variety show "The Strongest Boss" invites them to play a game. The host writes three positive integers $s, m, n$, then tells Alice and Bob together that $s \le m \le n$ and what $s$ is. (That is, $s$ is the lower bound for the $m, n$ to be guessed.) Then the host privately tells Alice what $m \times n$ is, and privately tells Bob what $m + n$ is.
Of course, if one person knows both $m \times n$ and $m + n$, they can easily compute $m$ and $n$, but now Alice and Bob each know only one of them, and they can only answer the host’s questions without communicating. Starting from one of them, the host alternately asks the current respondent, “Do you know what $m$ and $n$ are?” The respondent can only answer “know” or “don’t know.”
For show effects and to demonstrate Alice and Bob’s brilliance, the host wants that after a total of $t$ “don’t know” answers, both Alice and Bob will know what $m$ and $n$ are. Now the host asks you to construct a pair $m$ and $n$ that satisfies the requirements.
Input Format
A single line in the form `s t` (where `` is `Alice` or `Bob`), where $s$ is the lower bound for the numbers to guess, `` is the person the host asks first, and $t$ is the total number of “don’t know” answers from Alice and Bob.
Output Format
Output two integers $m$ and $n$ (separated by a space), representing one valid solution. If there are multiple solutions, output the one with the smallest $m + n$. If there are still multiple, among those with minimal $m + n$, output the one with the smallest $m$.
Explanation/Hint
#### Sample 1 Explanation
The host tells Alice and Bob that $5 \le m \le n$, privately tells Alice $m \times n = 60$, and privately tells Bob $m + n = 16$. The questioning process:
- The host asks Bob; Bob says “don’t know.”
- The host asks Alice; Alice says “don’t know.”
- The host asks Bob; Bob says “know.”
- The host asks Alice; Alice says “know.”
#### Sample 2 Explanation
The host tells Alice and Bob that $2 \le m \le n$, privately tells Alice $m \times n = 16$, and privately tells Bob $m + n = 8$. The questioning process:
- The host asks Alice; Alice says “don’t know.”
- The host asks Bob; Bob says “don’t know.”
- The host asks Alice; Alice says “don’t know.”
- The host asks Bob; Bob says “know.”
- The host asks Alice; Alice says “know.”
#### Constraints and Conventions
- For $40\%$ of the testdata, $t = 2$.
- For $100\%$ of the testdata, $1 \le s \le 200$, $2 \le t \le 15$, and a solution exists.
Translated by ChatGPT 5