题库练习 A.M. Deviation
← 上一题 下一题 →

A14567 | A.M. Deviation

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

A number $a_2$ is said to be the arithmetic mean of two numbers $a_1$ and $a_3$ , if the following condition holds: $a_1 + a_3 = 2\cdot a_2$ .

We define an arithmetic mean deviation of three numbers $a_1$ , $a_2$ and $a_3$ as follows: $d(a_1, a_2, a_3) = |a_1 + a_3 - 2 \cdot a_2|$ .

Arithmetic means a lot to Jeevan. He has three numbers $a_1$ , $a_2$ and $a_3$ and he wants to minimize the arithmetic mean deviation $d(a_1, a_2, a_3)$ . To do so, he can perform the following operation any number of times (possibly zero):

- Choose $i, j$ from $\{1, 2, 3\}$ such that $i \ne j$ and increment $a_i$ by $1$ and decrement $a_j$ by $1$

Help Jeevan find out the minimum value of $d(a_1, a_2, a_3)$ that can be obtained after applying the operation any number of times.

输入格式

The first line contains a single integer $t$ $(1 \le t \le 5000)$ — the number of test cases.

The first and only line of each test case contains three integers $a_1$ , $a_2$ and $a_3$ $(1 \le a_1, a_2, a_3 \le 10^{8})$ .

输出格式

For each test case, output the minimum value of $d(a_1, a_2, a_3)$ that can be obtained after applying the operation any number of times.

输入输出样例

输入 #1
3
3 4 5
2 2 6
1 6 5
输出 #1
0
1
0
C++ 编辑器
输入
输出