A15285 | Colored Balls: Revisited
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The title is a reference to the very first Educational Round from our writers team, Educational Round 18.
There is a bag, containing colored balls. There are $n$ different colors of balls, numbered from $1$ to $n$ . There are $\mathit{cnt}_i$ balls of color $i$ in the bag. The total amount of balls in the bag is odd (e. g. $\mathit{cnt}_1 + \mathit{cnt}_2 + \dots + \mathit{cnt}_n$ is odd).
In one move, you can choose two balls with different colors and take them out of the bag.
At some point, all the remaining balls in the bag will have the same color. That's when you can't make moves anymore.
Find any possible color of the remaining balls.
There is a bag, containing colored balls. There are $n$ different colors of balls, numbered from $1$ to $n$ . There are $\mathit{cnt}_i$ balls of color $i$ in the bag. The total amount of balls in the bag is odd (e. g. $\mathit{cnt}_1 + \mathit{cnt}_2 + \dots + \mathit{cnt}_n$ is odd).
In one move, you can choose two balls with different colors and take them out of the bag.
At some point, all the remaining balls in the bag will have the same color. That's when you can't make moves anymore.
Find any possible color of the remaining balls.
输入格式
The first line contains a single integer $t$ ( $1 \le t \le 1000$ ) — the number of testcases.
The first line of each testcase contains a single integer $n$ ( $1 \le n \le 20$ ) — the number of colors.
The second line contains $n$ integers $\mathit{cnt}_1, \mathit{cnt}_2, \dots, \mathit{cnt}_n$ ( $1 \le \mathit{cnt}_i \le 100$ ) — the amount of balls of each color in the bag.
The total amount of balls in the bag is odd (e. g. $\mathit{cnt}_1 + \mathit{cnt}_2 + \dots + \mathit{cnt}_n$ is odd).
The first line of each testcase contains a single integer $n$ ( $1 \le n \le 20$ ) — the number of colors.
The second line contains $n$ integers $\mathit{cnt}_1, \mathit{cnt}_2, \dots, \mathit{cnt}_n$ ( $1 \le \mathit{cnt}_i \le 100$ ) — the amount of balls of each color in the bag.
The total amount of balls in the bag is odd (e. g. $\mathit{cnt}_1 + \mathit{cnt}_2 + \dots + \mathit{cnt}_n$ is odd).
输出格式
For each testcase, print a single integer — any possible color of the remaining balls, after you made some moves and can't make moves anymore.
输入输出样例
输入 #1
3 3 1 1 1 1 9 2 4 7
输出 #1
3 1 2
In the first testcase, your first and only move can be one of the following:
- take balls with colors $1$ and $2$ ;
- take balls with colors $1$ and $3$ ;
- take balls with colors $2$ and $3$ .
After the move, exactly one ball will remain. Its color can be $3, 2$ or $1$ depending on the move.
In the second testcase, you can't make moves at all — there is only color of balls already. This color is $1$ .
In the third testcase, you can keep removing one ball of color $1$ and one ball of color $2$ until there are no more balls of color $1$ . At the end, three balls of color $2$ remain.
- take balls with colors $1$ and $2$ ;
- take balls with colors $1$ and $3$ ;
- take balls with colors $2$ and $3$ .
After the move, exactly one ball will remain. Its color can be $3, 2$ or $1$ depending on the move.
In the second testcase, you can't make moves at all — there is only color of balls already. This color is $1$ .
In the third testcase, you can keep removing one ball of color $1$ and one ball of color $2$ until there are no more balls of color $1$ . At the end, three balls of color $2$ remain.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted