【Codeforces Round 375 (Div 2) A】【水题】The New Year Meeting Friends
来源:互联网 发布:长春知满天教育 编辑:程序博客网 时间:2024/06/05 06:35
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 pointx2, 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.
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.
Print one integer — the minimum total distance the friends need to travel in order to meet together.
7 1 4
6
30 20 10
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 point4), 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<string.h>#include<string>#include<ctype.h>#include<math.h>#include<set>#include<map>#include<vector>#include<queue>#include<bitset>#include<algorithm>#include<time.h>using namespace std;void fre() { freopen("c://test//input.in", "r", stdin); freopen("c://test//output.out", "w", stdout); }#define MS(x,y) memset(x,y,sizeof(x))#define MC(x,y) memcpy(x,y,sizeof(x))#define ls o<<1#define rs o<<1|1typedef long long LL;typedef unsigned long long UL;typedef unsigned int UI;template <class T1, class T2>inline void gmax(T1 &a, T2 b) { if (b>a)a = b; }template <class T1, class T2>inline void gmin(T1 &a, T2 b) { if (b<a)a = b; }const int N = 0, M = 0, Z = 1e9 + 7, inf = 0x3f3f3f3f;template <class T1, class T2>inline void gadd(T1 &a, T2 b) { a = (a + b) % Z; }int n;int a[3];int main(){while (~scanf("%d%d%d", &a[0],&a[1],&a[2])){sort(a, a + 3);printf("%d\n", a[2] - a[0]);}return 0;}
- 【Codeforces Round 375 (Div 2) 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
- The New Year: Meeting Friends Codeforces Round#375-A
- [codeforces]A. 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 The New Year: Meeting Friends
- A. The New Year: Meeting Friends
- Codeforces723 A. The New Year: Meeting Friends (水题)
- Codeforces Round #371 (Div. 2) A. Meeting of Old Friends
- Codeforces 723A The New Year: Meeting Friends(题意有偏差的水题)
- codeforces——723A—— The New Year: Meeting Friends
- CodeForces 723A he New Year: Meeting Friends
- Codeforce 723A - The New Year: Meeting Friends
- tomcat端口号冲突的处理
- ListView优化机制及滑动时数据时出现的数据错乱重复问题
- 神马聊天——Swing使用的一些小技巧
- 非管理员权限,cmd输入java有效,输入javac无效解决方案
- kernelbase.dll ,远程登录打开软件有问题,远端登录打不开软件
- 【Codeforces Round 375 (Div 2) A】【水题】The New Year Meeting Friends
- 【Codeforces Round 375 (Div 2) B】【水模拟】Text Document Analysis
- 【Codeforces Round 375 (Div 2) C】【语文题】Polycarp at the Radio
- 如何理解全栈工程师?
- C语言实现单层感知器
- 【Codeforces Round 375 (Div 2) D】【简单dfs】Lakes in Berland
- 用flask开发个人博客(20)—— 利用模型创建数据库
- opencv——cvPyrSegmentation
- 数据库主外键详解