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. jQuery下拉列表二级联动插件

    jQuery下拉列表二级联动插件的视图代码: <!doctype html> <html lang="en"> <head> <meta ...

  2. Maven如何打包本地依赖包

    有的jar包,在maven中心库里面是没有的,那么,如何在项目中使用呢? 假设我们需要使用:apache-ant-zip-2.3.jar 将该jar包,放在项目的lib目录,例如: 在pom.xml里 ...

  3. More on understanding sort_buffer_size

    There have been a few posts by Sheeri and Baron today on the MySQL sort_buffer_size variable. I want ...

  4. LA2995 Image is everything

    蓝书P12 #include <cstdio> #include <cstring> #include <cmath> #include <algorithm ...

  5. TCP ------ RST的产生

    产生RST的几个原因 1.请求超时 有89.27两台主机.主机89向主机27发送了一个SYN,表示希望连接8888端口,主机27回应了主机89一个SYN表示可以连接.但是主机89莫名其妙的发送了一个R ...

  6. MySQL rpm 版本安装

     准备: [root@localhost moudles]# ls MySQL-client-5.6.36-1.linux_glibc2.5.x86_64.rpm MySQL-server-5.6.3 ...

  7. bootstrap再次回顾认识到的东西

    1,需要使用html5文档类型(Doctype),因此在使用bootstrap项目的开头包含下面的代码段. <!DOCTYPE html> <html> ....... < ...

  8. Android 实现对图片 Exif 的修改(Android 自带的方法)

    很多时候我们都要对我们的图片信息进行一些处理,比如向图片中写入经纬度,拍摄时间,设备信息,作者等等. 这个时候我们就要对我们的图片Exif进行写入信息的操作,当然,我们想知道图片的Exif信息,也可以 ...

  9. java 身份证15位转18位

    /** * 根据身份证号获取性别 * * @param pid * 身份证号 * @return 性别 F为女M为男 */ public static String getSexByPid(Strin ...

  10. Linux下部署weblogic应用

    1.Linux下weblogic安装 2.Linux下设置weblogic监听服务器地址(默认为本机) 1).修改domain\config\config.xml文件 修改 <server> ...