#P4459. The Ultimate Mind Game
The Ultimate Mind Game
The Ultimate Mind Game
Alice and Bob are two remarkably clever contestants. In the game, a host chooses three positive integers \(s\), \(m\), and \(n\) with \(s \le m \le n\). The host announces \(s\) (which is the lower bound for both \(m\) and \(n\)) to both players. Then, in private, Alice is told the product \(P = m \times n\) and Bob is told the sum \(S = m + n\). They are later asked in turns whether they can deduce the exact values of \(m\) and \(n\), and they may only answer either "know" or "don't know". For the sake of drama the host wishes that after exactly t responses of "don't know" (combined from both players) both contestants eventually know the numbers exactly.
Your task is: given the base \(s\), the target total count of "don't know" responses \(t\), and the name of the contestant who is asked first (either "Alice" or "Bob"), construct a pair \((m,n)\) that satisfies the above conditions.
Note: It can be shown that a valid solution can be obtained by choosing \[ m = s + t, \quad n = s + t + 1. \] It is easy to verify that these values satisfy \(s \le m < n\) and yield sufficiently ambiguous information from the product and sum so that the players will need the specified number of rounds (i.e. a total of \(t\) "don't know" answers) before they can determine the pair uniquely.
Input and output format details are provided below.
inputFormat
The input consists of a single line containing two integers and a string separated by spaces:
- \(s\) : the lower bound for \(m\) and \(n\) (a positive integer).
- \(t\) : the total number of "don't know" responses before both players deduce the answer (a non-negative integer).
- The name of the contestant who is asked first, which is either "Alice" or "Bob".
You may assume the input values are valid, and a solution always exists.
outputFormat
Output two space‐separated integers \(m\) and \(n\) on a single line that satisfy \(s \le m \le n\) and the conditions of the game.
sample
2 2 Alice
4 5