# A. The New Year: Meeting Friends

## 题目连接：

http://codeforces.com/contest/723/problem/A

## Description

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.

7 1 4

6

## 代码

``````#include<bits/stdc++.h>
using namespace std;

int main()
{
long long x1,x2,x3;
long long ans = 1e9;
cin>>x1>>x2>>x3;
for(int i=-10000;i<=10000;i++)
{
ans = min(ans,abs(x1-i)+abs(x2-i)+abs(x3-i));
}
cout<<ans<<endl;
}``````

## Codeforces Round #375 (Div. 2) A. The New Year: Meeting Friends 水题的更多相关文章

1. Codeforces Round #356 (Div. 2)B. Bear and Finding Criminals（水题）

B. Bear and Finding Criminals time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

2. Codeforces Round #343 (Div. 2) A. Far Relative’s Birthday Cake 水题

A. Far Relative's Birthday Cake 题目连接: http://www.codeforces.com/contest/629/problem/A Description Do ...

3. Codeforces Round #385 (Div. 2) A. Hongcow Learns the Cyclic Shift 水题

A. Hongcow Learns the Cyclic Shift 题目连接: http://codeforces.com/contest/745/problem/A Description Hon ...

4. Codeforces Round #396 (Div. 2) A. Mahmoud and Longest Uncommon Subsequence 水题

A. Mahmoud and Longest Uncommon Subsequence 题目连接: http://codeforces.com/contest/766/problem/A Descri ...

5. Codeforces Round #258 (Div. 2) C. Predict Outcome of the Game 水题

C. Predict Outcome of the Game 题目连接: http://codeforces.com/contest/451/problem/C Description There a ...

6. Codeforces Round #359 (Div. 2) B. Little Robber Girl&#39;s Zoo 水题

B. Little Robber Girl's Zoo 题目连接: http://www.codeforces.com/contest/686/problem/B Description Little ...

7. Codeforces Round #358 (Div. 2)　B. Alyona and Mex　水题

B. Alyona and Mex 题目连接: http://www.codeforces.com/contest/682/problem/B Description Someone gave Aly ...

8. 【打CF，学算法——二星级】Codeforces Round #313 (Div. 2) B. Gerald is into Art（水题）

[CF简单介绍] 提交链接:http://codeforces.com/contest/560/problem/B 题面: B. Gerald is into Art time limit per t ...

9. Codeforces Round #294 (Div. 2)A - A and B and Chess 水题

A. A and B and Chess time limit per test 1 second memory limit per test 256 megabytes input standard ...

## 随机推荐

1. 关于iframe

iframe一般用来嵌套其他页面来使用 1.如何使用? <iframe id="iframe1" src="2.html" frameborder=&qu ...

2. 跟着百度学PHP[4]OOP面对对象编程-12-抽象类

什么是抽象方法?我们在类里面定义的没有方法体的方法就是抽象方法.所谓的没有方法体指的是,在方法声明的时候没有大括号以及其中的内容,而是直接在声明时在方法名后加上分号结束,另外在声明抽象方法时还要加一个 ...

3. Linux makefile 教程 很具体，且易懂

4. Mobile Matrices

This is an attempt to compile a list of relevant specifications for all modern smart phones and mobi ...

5. gets和fgets函数的区别

1. gets与fgets gets函数原型:char*gets(char*buffer);//读取字符到数组:gets(str);str为数组名. gets函数功能:从键盘上输入字符,直至接受到换行 ...

6. .NET基础——运算符

这一篇我们来讲解C#中的运算符 1. C#中的算术运算符 5个算数运算符:+  -  *  /  %     它们都是二元运算符,*  /  % 的运算优先级相同,并且高于 +  - ,+  - 的运 ...

7. 淘宝的数据库拆分（TDDL）（转）

淘宝的数据拆分历程 系 统刚开始的时候,因为系统刚上线,用户不多,那个时候,所有的数据都放在了同一个数据库中,这个时候因为用户少压力小,一个数据库完全可以应付的了,但是 随着运营那些哥们辛苦的呐喊和拼 ...

8. Netty之心跳检测技术(四)

Netty之心跳检测技术(四) 一.简介 "心跳"听起来感觉很牛X的样子,其实只是一种检测端到端连接状态的技术.举个简单的"栗子",现有A.B两端已经互相连接, ...

9. 百度地图开发之POI数据检索

前面学习百度地图的一些基本的用法,这次我们一起来看一看百度地图的检索功能吧 poi检索api的基本用法 百度地图的POI类中共有如下几个方法 PoiBoundSearchOption POI范围内检索 ...

10. BZOJ5418[Noi2018]屠龙勇士——exgcd+扩展CRT+set

题目链接: [Noi2018]屠龙勇士 题目大意:有\$n\$条龙和初始\$m\$个武器,每个武器有一个攻击力\$t_{i}\$,每条龙有一个初始血量\$a_{i}\$和一个回复值\$p_{i}\$(即只要血量为负数就一 ...