A13642 | Integer Game
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
This is an interactive problem.
Anton and Harris are playing a game to decide which of them is the king of problemsetting.
There are three piles of stones, initially containing $a$ , $b$ , and $c$ stones, where $a$ , $b$ , and $c$ are distinct positive integers. On each turn of the game, the following sequence of events takes place:
- The first player chooses a positive integer $y$ and provides it to the second player.
- The second player adds $y$ stones to one of the piles, with the condition that he cannot choose the same pile in two consecutive turns.
The second player loses if, at any point, two of the piles contain the same number of stones. The first player loses if $1000$ turns have passed without the second player losing.
Feeling confident in his skills, Anton decided to let Harris choose whether he wants to go first or second. Help Harris defeat Anton and become the king of problemsetting!
Anton and Harris are playing a game to decide which of them is the king of problemsetting.
There are three piles of stones, initially containing $a$ , $b$ , and $c$ stones, where $a$ , $b$ , and $c$ are distinct positive integers. On each turn of the game, the following sequence of events takes place:
- The first player chooses a positive integer $y$ and provides it to the second player.
- The second player adds $y$ stones to one of the piles, with the condition that he cannot choose the same pile in two consecutive turns.
The second player loses if, at any point, two of the piles contain the same number of stones. The first player loses if $1000$ turns have passed without the second player losing.
Feeling confident in his skills, Anton decided to let Harris choose whether he wants to go first or second. Help Harris defeat Anton and become the king of problemsetting!
输入格式
The first line of input contains three distinct positive integers $a$ , $b$ , and $c$ ( $1 \le a, b, c \le 10^9$ ) — the initial number of stones in piles $1$ , $2$ , and $3$ respectively.
输出格式
The interaction begins by reading the integers $a$ , $b$ and $c$ .
After reading the integers, print a single line containing either "First" or "Second", denoting who you want to play as (as first or second correspondently).
On each turn, the first player (either you or the judge) must print a positive integer $y$ ( $1 \le y \le 10^{12}$ ).
Then, the second player must print $1$ , $2$ , or $3$ , indicating which pile should have $y$ stones added to it. From the second turn onwards, the pile that the second player chooses must be different from the pile that they chose on the previous turn.
If you are playing as Second and complete $1000$ turns without losing, or if you are playing as First and the judge has determined that it cannot make a move without losing, the interactor will print $0$ and will finish interaction. This means that your program is correct for this test case, and you should exit immediately.
If you are playing as First and complete $1000$ turns without winning, or if you are playing as Second and print a move that makes two piles have the same number of stones, or if you output an invalid move as either player, the interactor will print $-1$ and will finish interaction. You will receive a Wrong Answer verdict. Make sure to exit immediately to avoid getting other verdicts.
After printing something do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:
- fflush(stdout) or cout.flush() in C++;
- System.out.flush() in Java;
- flush(output) in Pascal;
- stdout.flush() in Python;
- see documentation for other languages.
In this problem, hacks are disabled.
After reading the integers, print a single line containing either "First" or "Second", denoting who you want to play as (as first or second correspondently).
On each turn, the first player (either you or the judge) must print a positive integer $y$ ( $1 \le y \le 10^{12}$ ).
Then, the second player must print $1$ , $2$ , or $3$ , indicating which pile should have $y$ stones added to it. From the second turn onwards, the pile that the second player chooses must be different from the pile that they chose on the previous turn.
If you are playing as Second and complete $1000$ turns without losing, or if you are playing as First and the judge has determined that it cannot make a move without losing, the interactor will print $0$ and will finish interaction. This means that your program is correct for this test case, and you should exit immediately.
If you are playing as First and complete $1000$ turns without winning, or if you are playing as Second and print a move that makes two piles have the same number of stones, or if you output an invalid move as either player, the interactor will print $-1$ and will finish interaction. You will receive a Wrong Answer verdict. Make sure to exit immediately to avoid getting other verdicts.
After printing something do not forget to output end of line and flush the output. Otherwise, you will get Idleness limit exceeded. To do this, use:
- fflush(stdout) or cout.flush() in C++;
- System.out.flush() in Java;
- flush(output) in Pascal;
- stdout.flush() in Python;
- see documentation for other languages.
In this problem, hacks are disabled.
输入输出样例
输入 #1
5 2 6 3 0
输出 #1
First 2 3
In the sample input, the piles initially have $5$ , $2$ , and $6$ stones. Harris decides to go first and provides the number $2$ to Anton. Anton adds $2$ stones to the third pile, which results in $5$ , $2$ , and $8$ .
In the next turn, Harris chooses $3$ . Note that Anton cannot add the stones to the third pile since he chose the third pile in the previous turn. Anton realizes that he has no valid moves left and reluctantly recognizes Harris as the king.
In the next turn, Harris chooses $3$ . Note that Anton cannot add the stones to the third pile since he chose the third pile in the previous turn. Anton realizes that he has no valid moves left and reluctantly recognizes Harris as the king.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted