问题 5304 --The New Year: Meeting Friends(新年访友)

5304: The New Year: Meeting Friends(新年访友)★★

时间限制: 1 Sec  内存限制: 256 MB
提交: 341  解决: 184
[提交][状态][命题人:]

题目描述

There are three friend living on the straight line  Ox  in Lineland. The first friend lives at the point  x[1] , the second friend lives at the point  x[2] , and the third friend lives at the point  x[3] . They plan to celebrate the New Year together, so they need to meet at one point. What is the minimum total distance they have to travel in order to meet at some point and celebrate the New Year?

It's guaranteed that the optimal answer is always integer.

有三位好朋友住在某个岛的一条直线上,第一、二、三个朋友分别住在点 x[1] 、x[2] 、x[3] 上。他们计划要一起庆祝新年,因此他们需要在某个点见面。请问他们移动到庆祝新年的点所需的最小移动距离为多少?

保证最优解为整数。

输入

The first line of the input contains three distinct integers  x[1]x[2] and x[3] (1 ≤ x[1], x[2], x[3] ≤ 100) — the coordinates of the houses of the first, the second and the third friends respectively.

输入的第一行包含三个不同的整数 x[1]、x[2] 和 x[3] (1≤x[1]、x[2]、x[3]≤100)——分别是第一个、第二个和第三个朋友的房子的坐标。

输出

Print one integer — the minimum total distance the friends need to travel in order to meet together.

输出一个整数,代表朋友们为了见面需要移动的最小总距离。

样例输入
Copy
样例输入1
7 1 4
样例输入2
30 20 10
样例输出
Copy
样例输出1
6
样例输出2
20

提示

In the first sample, friends should meet at the point 4. Thus, the first friend has to travel the distance of 3 (from the point 7 to the point 4), the second friend also has to travel the distance of 3 (from the point 1 to the point 4), while the third friend should not go anywhere because he lives at the point 4.

在第一个样例中,朋友应该在点 4 见面。因此,第一个朋友必须走 3 的距离(从点 7 到点 4 ),第二个朋友也必须走 3 的距离(从点 1 到点 4 ),而第三个朋友不应该去任何地方,因为他住在点4。

来源

 

[提交][状态]