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 ;
}

CodeForces723-A. The New Year: Meeting Friends的更多相关文章

  1. [LeetCode] Best Meeting Point 最佳开会地点

    A group of two or more people wants to meet and minimize the total travel distance. You are given a ...

  2. [LeetCode] Meeting Rooms II 会议室之二

    Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...

  3. [LeetCode] Meeting Rooms 会议室

    Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si ...

  4. Scrum Meeting 20161205

    本周Sprint Master 史少帅 一. 会议概要 作为一个新的sprint的开端,本次scrum meeting总结了每个人过去以来的工作,并明确了下一步的计划,具体如下: 工作总结: · 陈双 ...

  5. Beta阶段第十次Scrum Meeting

    情况简述 BETA阶段第十次Scrum Meeting 敏捷开发起始时间 2017/1/4 00:00 敏捷开发终止时间 2017/1/5 00:00 会议基本内容摘要 deadline到来 参与讨论 ...

  6. Beta阶段第九次Scrum Meeting

    情况简述 BETA阶段第九次Scrum Meeting 敏捷开发起始时间 2017/1/2 00:00 敏捷开发终止时间 2017/1/3 00:00 会议基本内容摘要 deadline临近 参与讨论 ...

  7. Beta阶段第八次Scrum Meeting

    情况简述 BETA阶段第八次Scrum Meeting 敏捷开发起始时间 2016/12/21 00:00 敏捷开发终止时间 2016/12/22 00:00 会议基本内容摘要 deadline临近 ...

  8. Beta阶段第七次Scrum Meeting

    Beta阶段第七次Scrum Meeting 情况简述 BETA阶段第七次Scrum Meeting 敏捷开发起始时间 2016/12/20 00:00 敏捷开发终止时间 2016/12/21 00: ...

  9. Beta阶段第六次Scrum Meeting

    情况简述 BETA阶段第六次Scrum Meeting 敏捷开发起始时间 2016/12/16 00:00 敏捷开发终止时间 2016/12/17 00:00 会议基本内容摘要 平稳推进 参与讨论人员 ...

  10. Daily Scrum Meeting 汇总

    Alpha Daily Scrum Meeting --FirstDay(11.8) Daily Scrum Meeting --SecondDay(11.9) Daily Scrum Meeting ...

随机推荐

  1. Intellij IDEA 像eclipse那样给maven添加依赖

    打开pom.xml,在它里面使用快捷键:ALT+Insert  ---->点击dependency 再输入想要添加的依赖关键字,比如:输个spring   出现下图: 根据需求选择版本,完成以后 ...

  2. 浅析 SpringMVC 原理和配置.

    一.原理 Spring MVC基于模型-视图-控制器(Model-View-Controller,MVC)模式实现,它能够帮你构建像Spring框架那样灵活和松耦合的Web应用程序,将请求处理的逻辑和 ...

  3. 关于spring mybateis 定义resultType="java.util.HashMap"

    关于spring mybateis  定义resultType="java.util.HashMap" List<HashMap<String, Object>& ...

  4. xamarin android制作圆角边框

    xamarin android制作圆角边框 效果图如下: 关键代码: drawable文件夹新建shape_corner_down.xml <?xml version="1.0&quo ...

  5. 算法分析| 小o和小ω符号

    渐近分析的主要思想是对不依赖于机器特定常数的算法的效率进行测量,主要是因为该分析不需要实现算法并且要比较程序所花费的时间. 我们已经讨论了三个主要的渐近符号.本文我们使用以下2个渐近符号表示算法的时间 ...

  6. bzoj 1835: [ZJOI2010]base 基站选址

    Description 有N个村庄坐落在一条直线上,第i(i>1)个村庄距离第1个村庄的距离为Di.需要在这些村庄中建立不超过K个通讯基站,在第i个村庄建立基站的费用为Ci.如果在距离第i个村庄 ...

  7. java 多线程,T1 T2 T3 顺序执行

    一.程序设计 1.抽象公共类PublicThread,具有先前线程属性previousThread.父类为Thread 2.在PublicThread的run()方法中判断previousThread ...

  8. Extjs 取消backspace事件

    Ext.getDoc().on('keydown',function(e){ if(e.getKey() == 8 && e.getTarget().type =='text' &am ...

  9. django xdmin使用

    我们来看看我们原先django给我们自带的admin后台是什么样子的呢 有人说,你的界面怎么那么丑,我说这个还叫丑吗,他说丑,我说你来,我看看你的,上图 看到登录界面后,我说别看了,我去修改,修改,我 ...

  10. 全国交通咨询系统 by C++ on Linux

    信息存储 利用邻接表存储城市信息与线路信息,比邻接矩阵更加高效. 主要数据结构 I)Time,规范时间的输入输出格式 II)VNode,头结点,用于建立顶点表,存储城市信息 III)ArcNode,表 ...