A14658 | Luntik and Concerts
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Luntik has decided to try singing. He has $a$ one-minute songs, $b$ two-minute songs and $c$ three-minute songs. He wants to distribute all songs into two concerts such that every song should be included to exactly one concert.
He wants to make the absolute difference of durations of the concerts as small as possible. The duration of the concert is the sum of durations of all songs in that concert.
Please help Luntik and find the minimal possible difference in minutes between the concerts durations.
He wants to make the absolute difference of durations of the concerts as small as possible. The duration of the concert is the sum of durations of all songs in that concert.
Please help Luntik and find the minimal possible difference in minutes between the concerts durations.
输入格式
The first line contains a single integer $t$ ( $1 \le t \le 1000$ ) — the number of test cases.
Each test case consists of one line containing three integers $a, b, c$ $(1 \le a, b, c \le 10^9)$ — the number of one-minute, two-minute and three-minute songs.
Each test case consists of one line containing three integers $a, b, c$ $(1 \le a, b, c \le 10^9)$ — the number of one-minute, two-minute and three-minute songs.
输出格式
For each test case print the minimal possible difference in minutes between the concerts durations.
输入输出样例
输入 #1
4 1 1 1 2 1 3 5 5 5 1 1 2
输出 #1
0 1 0 1
In the first test case, Luntik can include a one-minute song and a two-minute song into the first concert, and a three-minute song into the second concert. Then the difference will be equal to $0$ .
In the second test case, Luntik can include two one-minute songs and a two-minute song and a three-minute song into the first concert, and two three-minute songs into the second concert. The duration of the first concert will be $1 + 1 + 2 + 3 = 7$ , the duration of the second concert will be $6$ . The difference of them is $|7-6| = 1$ .
In the second test case, Luntik can include two one-minute songs and a two-minute song and a three-minute song into the first concert, and two three-minute songs into the second concert. The duration of the first concert will be $1 + 1 + 2 + 3 = 7$ , the duration of the second concert will be $6$ . The difference of them is $|7-6| = 1$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted