CodeForces 723A-The New Year: Meeting Friends(很水)
来源:互联网 发布:js字符串长度格式化 编辑:程序博客网 时间:2024/05/29 16:44
A. The New Year: Meeting Friends
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
There are three friend living on the straight line Ox in Lineland. The first friend lives at the point x1, the second friend lives at the point x2, and the third friend lives at the point x3. 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.
Input
The first line of the input contains three distinct integers x1, x2 and x3 (1 ≤ x1, x2, x3 ≤ 100) — the coordinates of the houses of the first, the second and the third friends respectively.
Output
Print one integer — the minimum total distance the friends need to travel in order to meet together.
Examples
input
7 1 4
output
6
input
30 20 10
output
20
Note
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.
题意:在一维数轴上给出三个人的位置,求出三个人相遇需要走的最小步数
代码
#include<stdio.h>#include<iostream>#include<algorithm>#include<string.h>using namespace std;int main(){ int num[4]; for(int i=0;i<3;i++) scanf("%d",&num[i]); sort(num,num+3); int result=num[1]-num[0]+num[2]-num[1]; printf("%d\n",result); return 0;}
- CodeForces 723A-The New Year: Meeting Friends(很水)
- Codeforces 723A The New Year: Meeting Friends
- 【69.77%】【codeforces 723A】The New Year: Meeting Friends
- Codeforces — 723A. The New Year: Meeting Friends
- Codeforces 723A-The New Year: Meeting Friends
- Codeforces 723A The New Year: Meeting Friends(题意有偏差的水题)
- [codeforces]A. The New Year: Meeting Friends 水题
- The New Year: Meeting Friends Codeforces Round#375-A
- Codeforces The New Year: Meeting Friends
- A. The New Year: Meeting Friends
- CodeForces 723A he New Year: Meeting Friends
- codeforces——723A—— The New Year: Meeting Friends
- Codeforces Round #375 (Div. 2)A. The New Year: Meeting Friends(水题)
- Codeforce 723A - The New Year: Meeting Friends
- Codeforces723 A. The New Year: Meeting Friends (水题)
- 【Codeforces Round 375 (Div 2) A】【水题】The New Year Meeting Friends
- Codeforces Round #375 (Div. 2) A-The New Year: Meeting Friends
- codeforces723AThe New Year: Meeting Friends+水题
- 启用了不安全的HTTP方法
- Jquery横向伸缩
- 如何方便快速在指定文件夹打开命令行
- C#中操纵SqlServer数据库
- Fragment调用PopupWindow工具封装类开启拍照或相册选择图片后无法回调的解决办法!
- CodeForces 723A-The New Year: Meeting Friends(很水)
- 工作总结25 Eclipse里Serve Modules without publishing导致项目加载不成功的主凶
- Jquery网站导航的 普通下拉菜单
- 第五届蓝桥杯软件类省赛真题-C-C-2_等额本金
- Bootstrap3 表单-被支持的控件:输入框
- study-10 linux系统网络基础知识及配置
- [BZOJ]1036: [ZJOI2008]树的统计Count
- ctfIDF实验室 啥?
- 解决润乾报表导出Excel后0丢失的问题