Codeforces Round #332 (Div. 2) A. Patrick and Shopping 水题
A. Patrick and Shopping
Time Limit: 20 Sec
Memory Limit: 256 MB
题目连接
http://codeforces.com/contest/599/problem/A
Description
Today Patrick waits for a visit from his friend Spongebob. To prepare for the visit, Patrick needs to buy some goodies in two stores located near his house. There is a d1 meter long road between his house and the first shop and a d2 meter long road between his house and the second shop. Also, there is a road of length d3 directly connecting these two shops to each other. Help Patrick calculate the minimum distance that he needs to walk in order to go to both shops and return to his house.
Patrick always starts at his house. He should visit both shops moving only along the three existing roads and return back to his house. He doesn't mind visiting the same shop or passing the same road multiple times. The only goal is to minimize the total distance traveled
Input
The first line of the input contains three integers d1, d2, d3 (1 ≤ d1, d2, d3 ≤ 108) — the lengths of the paths.
- d1 is the length of the path connecting Patrick's house and the first shop;
- d2 is the length of the path connecting Patrick's house and the second shop;
- d3 is the length of the path connecting both shops.
Output
Print the minimum distance that Patrick will have to walk in order to visit both shops and return to his house.
Sample Input
10 20 30
Sample Output
60
HINT
题意
给你从a-b的距离,a-c的距离,b-c的距离,然后问你从a走到bc然后再回到原点的最小距离是多少
题解:
只有4种情况,都考虑一下,然后就好了
代码
#include<iostream>
#include<math.h>
using namespace std; int main()
{
long long d1,d2,d3;
cin>>d1>>d2>>d3;
long long ans = d1+d3+d2;
ans = min(ans,2LL*d1+2LL*d3);
ans = min(ans,2LL*d2+2LL*d3);
ans = min(ans,2LL*d2+2LL*d1);
cout<<ans<<endl;
}
Codeforces Round #332 (Div. 2) A. Patrick and Shopping 水题的更多相关文章
- Codeforces Round #332 (Div. 2)A. Patrick and Shopping 水
A. Patrick and Shopping Today Patrick waits for a visit from his friend Spongebob. To prepare for ...
- Codeforces Round #332 (Div. 2) B. Spongebob and Joke 水题
B. Spongebob and Joke Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/599 ...
- Codeforces Round #297 (Div. 2)A. Vitaliy and Pie 水题
Codeforces Round #297 (Div. 2)A. Vitaliy and Pie Time Limit: 2 Sec Memory Limit: 256 MBSubmit: xxx ...
- Codeforces Round #290 (Div. 2) A. Fox And Snake 水题
A. Fox And Snake 题目连接: http://codeforces.com/contest/510/problem/A Description Fox Ciel starts to le ...
- Codeforces Round #322 (Div. 2) A. Vasya the Hipster 水题
A. Vasya the Hipster Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/581/p ...
- Codeforces Round #373 (Div. 2) B. Anatoly and Cockroaches 水题
B. Anatoly and Cockroaches 题目连接: http://codeforces.com/contest/719/problem/B Description Anatoly liv ...
- Codeforces Round #368 (Div. 2) A. Brain's Photos 水题
A. Brain's Photos 题目连接: http://www.codeforces.com/contest/707/problem/A Description Small, but very ...
- Codeforces Round #359 (Div. 2) A. Free Ice Cream 水题
A. Free Ice Cream 题目连接: http://www.codeforces.com/contest/686/problem/A Description After their adve ...
- Codeforces Round #355 (Div. 2) A. Vanya and Fence 水题
A. Vanya and Fence 题目连接: http://www.codeforces.com/contest/677/problem/A Description Vanya and his f ...
随机推荐
- Java-泛型编程-使用通配符? extends 和 ? super
原文地址:http://blog.csdn.net/fw0124/article/details/42296283 泛型中使用通配符有两种形式:子类型限定<? extends xxx>和超 ...
- 【转】Masonry介绍与使用实践(快速上手Autolayout)
原文网址:http://adad184.com/2014/09/28/use-masonry-to-quick-solve-autolayout/ 前言 1 MagicNumber -> aut ...
- Android Message和obtainMessage的区别
类概述 定义一个包含任意类型的描述数据对象,此对象可以发送给Handler.对象包含两个额外的int字段和一个额外的对象字段,这样可以使得在很多情况下不用做分配工作. 尽管Message的构造器是公开 ...
- Jabber/XMPP协议与架构
一.概述 由Jeremie Miller于1998年开始这个项目.Jabber是一个开放源码形式组织产生的网络实时通信协议,第一个公开版本于2000年5月发行.Jabber已经由IETF XMPP协议 ...
- sharepoint2010 创建自定义列表
转:http://boke.25k5.com/kan77298.html 如何创建自定义列表 首先了解创建自定义列表中涉及到的几个名词:栏.内容类型. ①栏:栏即列.字段(Field),MSDN中给出 ...
- 查看系统或者Jmeter的Properties
工作台-非测试元件-Property Display,可以显示系统或者Jmeter的Properties
- 仿酷狗音乐播放器开发日志十九——CTreeNodeUI的bug修复二(附源码)
转载请说明原出处,谢谢 今天本来打算把仿酷狗播放列表的子控件拖动插入功能做一下,但是仔细使用播放列表控件时发现了几个逻辑错误,由于我的播放 列表控件是基于CTreeViewUI和CTreeNodeUI ...
- Unicode转为UTF8
Unicode转换为UTF8 要说这个转换也简单,使用WideCharToMultiByte两次或者直接一次就可以转换. 今天在弄VLC的时候,由于VLC的视频文件名使用UTF8编码,因此当路径中包含 ...
- C#学习1
一.C#可以干什么? 1.桌面应用程序,WinForm 2.Internet应用程序,ASP.Net 3.手机开发,WindowsPhone8 二..Net开发学习路线 C#语言——>简单的Wi ...
- MFC学习20160718(GetModuleFileName&&GetAppDataPath)
1.标题栏设置 一.对话框标题栏内容为静态 直接在对话框属性“General”的“Caption”中修改. 二.对话框标题栏内容为动态生成的 在对应对话框的初始化函数OnInitDialog()中添加 ...