308832: CF1582A. Luntik and Concerts

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Luntik and Concerts

题意翻译

### 题目描述 有 $a$ 个 $1$ 分钟的音乐,$b$ 个 $2$ 分钟的音乐,$c$ 个 $3$ 分钟的音乐,将这些音乐分成 $2$ 组,使两组音乐的总时长之差的绝对值尽可能小。 ### 输入格式 第一行输入一个正整数 $t$ 表示数据组数。 接下来 $t$ 行每行三个正整数 $a,b,c$,表示一组数据,含义见题目描述。 ### 输出格式 对于每组数据输出一行一个整数表示两组音乐的总时长之差的绝对值的最小值。 ### 数据范围 $1\le t\le1000,1\le a,b,c\le10^9$。 ### 样例解释: 1. 第一组 $1$ 个 $1$ 分钟音乐、$2$ 个 $2$ 分钟音乐,第二组 $1$ 个 $3$ 分钟音乐时两组音乐总时长之差的绝对值最小,为 $0$。 2. 第一组 $2$ 个 $1$ 分钟音乐、$1$ 个 $2$ 分钟音乐$1$ 个 $3$ 分钟音乐,第二组 $2$ 个 $3$ 分钟音乐时两组音乐总时长之差的绝对值最小,为 $1$。 3. 第一组 $5$ 个 $1$ 分钟音乐、$5$ 个 $2$ 分钟音乐,第二组 $5$ 个 $3$ 分钟音乐时两组音乐总时长之差的绝对值最小,为 $0$。 4. 第一组 $1$ 个 $1$ 分钟音乐、$1$ 个 $3$ 分钟音乐,第二组 $1$ 个 $2$ 分钟音乐、$1$ 个 $3$ 分钟音乐时两组音乐总时长之差的绝对值最小,为 $1$。

题目描述

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.

输入输出格式

输入格式


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.

输出格式


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 $ .

Input

题意翻译

### 题目描述 有 $a$ 个 $1$ 分钟的音乐,$b$ 个 $2$ 分钟的音乐,$c$ 个 $3$ 分钟的音乐,将这些音乐分成 $2$ 组,使两组音乐的总时长之差的绝对值尽可能小。 ### 输入格式 第一行输入一个正整数 $t$ 表示数据组数。 接下来 $t$ 行每行三个正整数 $a,b,c$,表示一组数据,含义见题目描述。 ### 输出格式 对于每组数据输出一行一个整数表示两组音乐的总时长之差的绝对值的最小值。 ### 数据范围 $1\le t\le1000,1\le a,b,c\le10^9$。 ### 样例解释: 1. 第一组 $1$ 个 $1$ 分钟音乐、$2$ 个 $2$ 分钟音乐,第二组 $1$ 个 $3$ 分钟音乐时两组音乐总时长之差的绝对值最小,为 $0$。 2. 第一组 $2$ 个 $1$ 分钟音乐、$1$ 个 $2$ 分钟音乐$1$ 个 $3$ 分钟音乐,第二组 $2$ 个 $3$ 分钟音乐时两组音乐总时长之差的绝对值最小,为 $1$。 3. 第一组 $5$ 个 $1$ 分钟音乐、$5$ 个 $2$ 分钟音乐,第二组 $5$ 个 $3$ 分钟音乐时两组音乐总时长之差的绝对值最小,为 $0$。 4. 第一组 $1$ 个 $1$ 分钟音乐、$1$ 个 $3$ 分钟音乐,第二组 $1$ 个 $2$ 分钟音乐、$1$ 个 $3$ 分钟音乐时两组音乐总时长之差的绝对值最小,为 $1$。

加入题单

算法标签: