A10632 | The New Year: Meeting Friends
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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.
It's guaranteed that the optimal answer is always integer.
输入格式
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.
输出格式
Print one integer — the minimum total distance the friends need to travel in order to meet together.
输入输出样例
输入 #1
7 1 4
输出 #1
6
输入 #2
30 20 10
输出 #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$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted