CF2256A.Three Numbers on the Blackboard

入门

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Rain is falling outside the Fairy Warehouse, so Chtholly, Nephren, and Ithea spend the afternoon playing a game in the common room.

Ithea writes three non-negative integers aa, bb, and cc on the blackboard.

Chtholly may perform the following operation an arbitrary number of times (possibly zero):

  • Choose one of the three current integers and replace it with the sum of the other two current integers. The other two integers remain unchanged.

For example, starting from (3,5,11)(3,5,11), she can replace 1111 with 3+53+5, obtaining (3,5,8)(3,5,8).

Nephren wants to know the minimum range∗^{\text{∗}} of the three integers that Chtholly can obtain. Help her find it!

∗^{\text{∗}}The range of a non-empty finite collection of numbers is defined as its maximum value minus its minimum value. In particular, the range of three numbers xx, yy, and zz is max⁡(x,y,z)−min⁡(x,y,z)\max(x,y,z)-\min(x,y,z).

外面正在下雨,于是小精灵仓库里的Chtholly、Nephren和Ithea下午在公共休息室里玩起了一个游戏。

Ithea在黑板上写下三个非负整数 aa、bb 和 cc。

Chtholly 可以执行以下操作任意多次(包括零次):

  • 从当前三个整数中任选一个,并将其替换为其余两个当前整数的和;其余两个整数保持不变。

例如,从 (3,5,11)(3,5,11) 出发,她可将 1111 替换为 3+53+5,从而得到 (3,5,8)(3,5,8)。

Nephren 想知道:Chtholly 能够得到的三个整数的最小范围∗^{\text{∗}} 是多少?请帮她找出这个最小值!

∗^{\text{∗}} 一个非空有限数集的范围定义为该集合中的最大值减去最小值。特别地,三个数 xx、yy、zz 的范围为 max⁡(x,y,z)−min⁡(x,y,z)\max(x,y,z)-\min(x,y,z)。

输入格式

Each test contains multiple test cases. The first line contains the number of test cases tt (1≤t≤1001 \le t \le 100). The description of the test cases follows.

The only line of each test case contains three integers aa, bb, and cc (0≤a,b,c≤1090 \le a,b,c \le 10^9) — the integers initially written on the blackboard.

每个测试包含多个测试用例。第一行包含测试用例的数量 tt(1≤t≤1001 \le t \le 100)。随后是测试用例的描述。

每个测试用例仅有一行,包含三个整数 aa、bb 和 cc(0≤a,b,c≤1090 \le a,b,c \le 10^9)——即最初写在黑板上的三个整数。

输出格式

For each test case, output a single integer — the minimum possible range of the three integers.

对于每个测试用例,输出一个整数——这三个整数可能的最小范围。

输入输出样例

  • 输入#1

    6
    5 5 5
    4 6 9
    2 3 10
    0 0 7
    2 3 5
    20 4 5

    输出#1

    0
    5
    3
    0
    3
    5

说明/提示

In the first test case, all three integers are already equal, so their range is 00.

In the second test case, performing no operation gives the range 9−4=59-4=5. It can be shown that no sequence of operations can produce a smaller range.

In the third test case, Chtholly can replace 1010 with 2+3=52+3=5. The three integers become (2,3,5)(2,3,5), whose range is 5−2=35-2=3.

In the fourth test case, Chtholly can replace 77 with 0+0=00+0=0. All three integers then become 00.

在第一个测试用例中,三个整数已经相等,因此它们的极差为 00。

在第二个测试用例中,不执行任何操作时,极差为 9−4=59-4=5。可以证明,不存在任何操作序列能得到更小的极差。

在第三个测试用例中,Chtholly 可以将 1010 替换为 2+3=52+3=5。三个整数变为 (2,3,5)(2,3,5),其极差为 5−2=35-2=3。

在第四个测试用例中,Chtholly 可以将 77 替换为 0+0=00+0=0。此时三个整数均变为 00。

输入解题思路,AI测评打分。不知道怎么写?

首页