308962: CF1605A. A.M. Deviation
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
A.M. Deviation
题意翻译
## 题目描述 给出 3 个数 $a_1,a_2,a_3$,现有一种操作可以在 $a_1,a_2,a_3$ 中任选两个数,使其中一个 +1,另一个 -1。操作次数不限。 要求最小化 $|a_1+a_3-2\times a_2|$。 ## 输入格式 第一行输入一个整数 $t$ 表示数据组数。 每组数据读入一行 3 个整数 $a_1,a_2,a_3$。 ## 输出格式 对于每组数据输出一行一个整数表示最小的 $|a_1+a_3-2\times a_2|$。 ## 数据范围 $1\le t\le 5000,1\le a_1,a_2,a_3\le 10^8$。题目描述
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