A15002 | Log Chopping
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
There are $n$ logs, the $i$ -th log has a length of $a_i$ meters. Since chopping logs is tiring work, errorgorn and maomao90 have decided to play a game.
errorgorn and maomao90 will take turns chopping the logs with errorgorn chopping first. On his turn, the player will pick a log and chop it into $2$ pieces. If the length of the chosen log is $x$ , and the lengths of the resulting pieces are $y$ and $z$ , then $y$ and $z$ have to be positive integers, and $x=y+z$ must hold. For example, you can chop a log of length $3$ into logs of lengths $2$ and $1$ , but not into logs of lengths $3$ and $0$ , $2$ and $2$ , or $1.5$ and $1.5$ .
The player who is unable to make a chop will be the loser. Assuming that both errorgorn and maomao90 play optimally, who will be the winner?
errorgorn and maomao90 will take turns chopping the logs with errorgorn chopping first. On his turn, the player will pick a log and chop it into $2$ pieces. If the length of the chosen log is $x$ , and the lengths of the resulting pieces are $y$ and $z$ , then $y$ and $z$ have to be positive integers, and $x=y+z$ must hold. For example, you can chop a log of length $3$ into logs of lengths $2$ and $1$ , but not into logs of lengths $3$ and $0$ , $2$ and $2$ , or $1.5$ and $1.5$ .
The player who is unable to make a chop will be the loser. Assuming that both errorgorn and maomao90 play optimally, who will be the winner?
输入格式
Each test contains multiple test cases. The first line contains a single integer $t$ ( $1 \leq t \leq 100$ ) — the number of test cases. The description of the test cases follows.
The first line of each test case contains a single integer $n$ ( $1 \leq n \leq 50$ ) — the number of logs.
The second line of each test case contains $n$ integers $a_1,a_2, \ldots, a_n$ ( $1 \leq a_i \leq 50$ ) — the lengths of the logs.
Note that there is no bound on the sum of $n$ over all test cases.
The first line of each test case contains a single integer $n$ ( $1 \leq n \leq 50$ ) — the number of logs.
The second line of each test case contains $n$ integers $a_1,a_2, \ldots, a_n$ ( $1 \leq a_i \leq 50$ ) — the lengths of the logs.
Note that there is no bound on the sum of $n$ over all test cases.
输出格式
For each test case, print "errorgorn" if errorgorn wins or "maomao90" if maomao90 wins. (Output without quotes).
输入输出样例
输入 #1
2 4 2 4 2 1 1 1
输出 #1
errorgorn maomao90
In the first test case, errorgorn will be the winner. An optimal move is to chop the log of length $4$ into $2$ logs of length $2$ . After this there will only be $4$ logs of length $2$ and $1$ log of length $1$ .
After this, the only move any player can do is to chop any log of length $2$ into $2$ logs of length $1$ . After $4$ moves, it will be maomao90's turn and he will not be able to make a move. Therefore errorgorn will be the winner.
In the second test case, errorgorn will not be able to make a move on his first turn and will immediately lose, making maomao90 the winner.
After this, the only move any player can do is to chop any log of length $2$ into $2$ logs of length $1$ . After $4$ moves, it will be maomao90's turn and he will not be able to make a move. Therefore errorgorn will be the winner.
In the second test case, errorgorn will not be able to make a move on his first turn and will immediately lose, making maomao90 the winner.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted