codeforces 723A : The New Year: Meeting Friends
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.
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 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.
正解:模拟
解题报告:
水题,模拟即可。
//It is made by jump~
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <ctime>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;
typedef long long LL;
const int inf = (<<);
int a[];
int pos;
int ans; inline int getint()
{
int w=,q=; char c=getchar();
while((c<'' || c>'') && c!='-') c=getchar(); if(c=='-') q=,c=getchar();
while (c>='' && c<='') w=w*+c-'', c=getchar(); return q ? -w : w;
} inline void work(){
for(int i=;i<=;i++) a[i]=getint();
sort(a+,a+); ans+=a[]-a[]; ans+=a[]-a[];
printf("%d",ans);
} int main()
{
work();
return ;
}
codeforces 723A : The New Year: Meeting Friends的更多相关文章
- CodeForces 723A The New Year: Meeting Friends (水题)
题意:给定 3 个数,求其中一个数到另外两个数之间的最短距离. 析:很明显选中间那个点了. 代码如下: #pragma comment(linker, "/STACK:1024000000, ...
- 【69.77%】【codeforces 723A】The New Year: Meeting Friends
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- Codefoces 723A The New Year: Meeting Friends
A. The New Year: Meeting Friends time limit per test:1 second memory limit per test:256 megabytes in ...
- codeforces round 433 D. Jury Meeting
题目大意: 输入n,m,k,分别代表城市的数量,城市编号1~n,航班的数量以及会议必须所有人员到会一起商议的天数,然后及时输入m行航班的信息,每一行输入d,f,t,c分别表示航班到站和始发的那一天(始 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 043医疗项目-模块四:采购单模块—采购单明细查询(Dao,Service,Action三层)
前一篇文章我们做的是在医院的角度上添加在采购单里面添加药品.这一篇文章是查看我们添加的采购单信息. 我们先看一下要实现的效果:当: 按下确认添加时,会在这里 显示出刚才添加的数据. 好,我们就来做这个 ...
- 033医疗项目-模块三:药品供应商目录模块——供货商药品目录t添加查询功能----------Dao层和Service层和Action层和调试
什么叫做供货商药品目录t添加查询功能?就是说我们前面的博客里面不是说供货商登录后看到了自己供应的药品了么如下: 现在供货商想要往里面添加别的药品,那么这个药品的来源就是卫生局提供的那个Ypxx表(药品 ...
- 返回标量CLR自定义函数
昨天有学习了返回表自定义函数<CLR Table-Valued函数>http://www.cnblogs.com/insus/p/4378354.html.今天学习另一个,实现返回标量(S ...
- IntelliJ IDEA 13试用手记(附详细截图)
从去年开始转java以来,一直在寻找一款趁手的兵器,eclipse虽然是很多java程序员的首选,但是我发现一旦安装了一些插件,workspace中的项目达到数10个以后,经常崩溃,实在影响编程的心情 ...
- 发布我的图片预加载控件YPreLoadImg v1.0
介绍 大家好!很高兴向大家介绍我的图片预加载控件YPreLoadImg.它可以帮助您预加载图片,并且能显示加载的进度,在预加载完成后调用指定的方法. YPreLoadImg控件由一个名为PreLoad ...
- Python2.6-原理之类和oop(下)
来自<python学习手册第四版>第六部分 五.运算符重载(29章) 这部分深入介绍更多的细节并看一些常用的重载方法,虽然不会展示每种可用的运算符重载方法,但是这里给出的代码也足够覆盖py ...
- asp.net、 mvc session影响并发
现象:在一个网站中,当访问一个处理比较耗时的页面(A页面),页面请求还没有返回时,此时再点击访问该网站的其他页面(B页面)会出现B页面很久都没有响应和返回,直到A页面输出返回数据时才开始处理B页面的请 ...
- 年终福利,PHP7+Apache2.4+MySQL5.6 源码编译安装,环境配置,搭建你自己的LAMP环境
PHP7 都出来了,你还在玩PHP5吗? MySQL5.6 早都出来了,你还在玩MySql5.2吗? Apache2.4 早都出来了,你还在玩Apache2.2吗? 笔者不才,愿意亲自搭建环境,供搭建 ...
- 深入学习JavaScript(二)
函数表达式和函数声明 函数声明 function 函数名(参数){函数体} 函数表达式 function 函数名(可选)(参数){函数体} 示例: function foo(){} // 声明,因为它 ...
- 一起来学node.js吧 node school简介
node.js这几年火爆的简直丧心病狂,去lagou.com查查node.js的职位,那叫一个多. 要说火爆到什么程度,竟然有一个网站专门去教大家学习node.js, Node School. 进去逛 ...