QOJ.ac

QOJ

总分: 100 仅输出

#2981. Two-Player Number Guessing Game

统计

Alice and Bob are very intelligent people who can calculate the optimal strategies for various games. Now, a variety show called "The Greatest Minds" has invited them to play a game. The host writes down three positive integers $s$, $m$, and $n$, and then tells Alice and Bob that $s \le m \le n$ and what the value of $s$ is. (That is, $s$ is the lower bound for the $m$ and $n$ they are about to guess.) Afterward, the host privately tells Alice the product of $m$ and $n$, and privately tells Bob the sum of $m$ and $n$.

Of course, if a person knew both the product and the sum of $m$ and $n$, they could easily calculate what $m$ and $n$ are. However, Alice and Bob only know one of these values each, and they can only answer the host's questions without communicating with each other. The host starts by asking either Alice or Bob (see Input) whether they know what $m$ and $n$ are, and they can only answer "know" or "don't know".

For the sake of the show and to demonstrate how intelligent Alice and Bob are, the host wants them to have said "don't know" a total of $t$ times before both of them know what $m$ and $n$ are. The host has now come to you, hoping you can help him construct a pair of $m$ and $n$ that satisfies these conditions.

Input

The input consists of a single line in the format "s t", where $s$ and $t$ are defined as in the problem description (note that Alice and Bob know the value of $s$), and is either "Alice" or "Bob", indicating who the host asks first.

Output

Output a single line containing two numbers separated by a space, representing a pair of $m$ and $n$ that satisfies the requirements. If there are multiple solutions, output the one with the smallest sum of $m$ and $n$. If there are still multiple solutions, output the one with the smallest $m$ among those with the smallest sum. The input data is guaranteed to have a solution.

Examples

Input 1

5 Bob 2

Output 1

6 10

Note 1

The host tells Alice and Bob $5 \le m \le n$, tells Alice $mn = 60$, and tells Bob $m + n = 16$.

The host asks Bob if he knows what $m$ and $n$ are, and Bob says he doesn't know. The host asks Alice if she knows what $m$ and $n$ are, and Alice says she doesn't know. The host asks Bob if he knows what $m$ and $n$ are, and Bob says he knows. The host asks Alice if she knows what $m$ and $n$ are, and Alice says she knows.

Input 2

2 Alice 3

Output 2

4 4

Note 2

The host tells Alice and Bob $2 \le m \le n$, tells Alice $mn = 16$, and tells Bob $m + n = 8$.

The host asks Alice if she knows what $m$ and $n$ are, and Alice says she doesn't know. The host asks Bob if he knows what $m$ and $n$ are, and Bob says he doesn't know. The host asks Alice if she knows what $m$ and $n$ are, and Alice says she doesn't know. The host asks Bob if he knows what $m$ and $n$ are, and Bob says he knows. The host asks Alice if she knows what $m$ and $n$ are, and Alice says she knows.

Alice and Bob each independently wrote down the correct $m$ and $n$, and the audience thinks Alice and Bob are very impressive.

Constraints

For 40% of the data, $t = 2$. For 100% of the data, $1 \le s \le 200$, $2 \le t \le 15$. The input data is guaranteed to have a solution.


或者逐个上传:

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.