time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard 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.

代码1:

#include<stdio.h>
int main(){
int a,b,c,t,dis;
while(~scanf("%d %d %d",&a,&b,&c)){
if(a<b)swap(a,b);if(a<c)swap(a,c);if(b<c)swap(b,c);
dis=a-c;
printf("%d\n",dis);
}
return ;
}

代码2:

#include<stdio.h>
#include<math.h>
int main(){
int a,b,c,dis,m;
while(~scanf("%d %d %d",&a,&b,&c)){
m=;
for(int i=;i<=;i++){
  dis=fabs(a-i)+fabs(b-i)+fabs(c-i);
   if(m>dis)
  m=dis;
}
printf("%d\n",m);
}
return ;
}

Codeforces 723 A. The New Year: Meeting Friends的更多相关文章

  1. Codeforces Round #371 (Div. 2) A. Meeting of Old Friends 水题

    A. Meeting of Old Friends 题目连接: http://codeforces.com/contest/714/problem/A Description Today an out ...

  2. 【69.77%】【codeforces 723A】The New Year: Meeting Friends

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  3. Codeforces水题集合[14/未完待续]

    Codeforces Round #371 (Div. 2) A. Meeting of Old Friends |B. Filya and Homework A. Meeting of Old Fr ...

  4. Codeforces Round #375 (Div. 2) A. The New Year: Meeting Friends 水题

    A. The New Year: Meeting Friends 题目连接: http://codeforces.com/contest/723/problem/A Description There ...

  5. codeforces 782B The Meeting Place Cannot Be Changed (三分)

    The Meeting Place Cannot Be Changed Problem Description The main road in Bytecity is a straight line ...

  6. Codeforces 714A Meeting of Old Friends

    A. Meeting of Old Friends time limit per test:1 second memory limit per test:256 megabytes input:sta ...

  7. Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals) B. The Meeting Place Cannot Be Changed

    地址:http://codeforces.com/contest/782/problem/B 题目: B. The Meeting Place Cannot Be Changed time limit ...

  8. Jury Meeting CodeForces - 854D

    Jury Meeting CodeForces - 854D 思路:暴力枚举会议开始的那一天(只需用所有向0点飞的航班的那一天+1去枚举即可),并计算所有人此情况下去0点和从0点出来的最小花费. 具体 ...

  9. Codeforces 420 B. Online Meeting

    B. Online Meeting time limit per test 1 second memory limit per test 256 megabytes input standard in ...

随机推荐

  1. 隐马尔可夫模型HMM

    隐马尔可夫模型HMM的探究 1 HMM基本概念1.1 定义1.2 观测序列生成过程1.3 HMM的三个问题2 概率计算算法2.1 直接计算算法2.2 前向算法forward algorithm2.3 ...

  2. 51nod 1967路径定向(欧拉回路)

    题目大意:给出一个图,安排边的方向,使得入度等于出度的点数最多,并给出方案. 首先假设是个无向图,不妨认定偶点必定可以满足条件 我们还会发现,奇点的个数必定是偶数个 那么如果把奇点两两用辅助边连起来, ...

  3. [洛谷P1892]团伙

    题目大意:有n个人,关系为:朋友的朋友是朋友,敌人的敌人是朋友.如果是朋友就在一个团队内,是敌人就不在,现在给出一关系,问最多有多少团伙.题解:并查集,建反集,如果是朋友,就把他们的并查集合并:如果是 ...

  4. Link Cat Tree (连喵树) 学习笔记

    Link Cat Tree 一.感性定义 所谓连喵树,即一种对森林支持修改,查询,连边,删边等操作的数据结构(姑且算她是吧).她用一颗颗互相连接的辅助树维护原森林的信息,辅助树相互连接的边叫虚边,辅助 ...

  5. HDU 5655 四边形判断

    CA Loves Stick Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others) ...

  6. Educational Codeforces Round 55 (Rated for Div. 2):D. Maximum Diameter Graph

    D. Maximum Diameter Graph 题目链接:https://codeforces.com/contest/1082/problem/D 题意: 给出n个点的最大入度数,要求添加边构成 ...

  7. bzoj 3771 Triple FFT 生成函数+容斥

    Triple Time Limit: 20 Sec  Memory Limit: 64 MBSubmit: 847  Solved: 482[Submit][Status][Discuss] Desc ...

  8. c++虚析构函数的必要性

    我们知道,用C++开发的时候,用来做基类的类的析构函数一般都是虚函数. 可是,为什么要这样做呢?下面用一个小例子来说明: #include<iostream> using namespac ...

  9. hive的体系架构及安装

    1,什么是Hive? Hive是能够用类SQL的方式操作HDFS里面数据一个数据仓库的框架,这个类SQL我们称之为HQL(Hive Query Language) 2,什么是数据仓库? 存放数据的地方 ...

  10. Spring - IoC(6): 作用域

    Spring 支持五种作用域,分别是 singleton.prototype.request.session 和 global session. 作用域 说明  singleton (默认作用域)单例 ...