【CodeForces 599A】D - 特别水的题4- Patrick and Shopping
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
60
1 1 5
4
Hint
The first sample is shown on the picture in the problem statement. One of the optimal routes is: house - first shop - second shop -house.
In the second sample one of the optimal routes is: house - first shop - house - second shop - house.
这题只要分4种情况,选择最短的路径就可以了
#include<stdio.h>
#include<algorithm>
using namespace std;
long long d1,d2,d3,ans;
int main(){ scanf("%lld%lld%lld",&d1,&d2,&d3);
ans=min(min(d1*+d3*,d2*+d3*),min(d1+d2+d3,d1*+d2*));
printf("%d",ans);
return ;
}
【CodeForces 599A】D - 特别水的题4- Patrick and Shopping的更多相关文章
- 【CodeForces 596A】E - 特别水的题5-Wilbur and Swimming Pool
Description After making bad dives into swimming pools, Wilbur wants to build a swimming pool in the ...
- 【 CodeForces 604A】B - 特别水的题2-Uncowed Forces
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=102271#problem/B Description Kevin Sun has jus ...
- 【CodeForces 606A】A -特别水的题1-Magic Spheres
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=102271#problem/A Description Carl is a beginne ...
- 【CodeForces 602A】C - 特别水的题3-Two Bases
http://acm.hust.edu.cn/vjudge/contest/view.action?cid=102271#problem/C Description After seeing the ...
- 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/5 ...
- Codeforces Round #378 (Div. 2) D题(data structure)解题报告
题目地址 先简单的总结一下这次CF,前两道题非常的水,可是第一题又是因为自己想的不够周到而被Hack了一次(或许也应该感谢这个hack我的人,使我没有最后在赛后测试中WA).做到C题时看到题目情况非常 ...
- CodeForces.158A Next Round (水模拟)
CodeForces.158A Next Round (水模拟) 题意分析 校赛水题的英文版,坑点就是要求为正数. 代码总览 #include <iostream> #include &l ...
- Codeforces Round #612 (Div. 2) 前四题题解
这场比赛的出题人挺有意思,全部magic成了青色. 还有题目中的图片特别有趣. 晚上没打,开virtual contest打的,就会前三道,我太菜了. 最后看着题解补了第四道. 比赛传送门 A. An ...
- Codeforces 828B Black Square(简单题)
Codeforces 828B Black Square(简单题) Description Polycarp has a checkered sheet of paper of size n × m. ...
随机推荐
- jquery/js特效代码总结(一):tab切换
jquery实现tab切换: html代码: <ul class="tabs" id="tabs01"> <li><a href= ...
- java 20 - 7 字节输入流的操作
字节输入流操作步骤: A:创建字节输入流对象 B:调用read()方法读取数据,并把数据显示在控制台 C:释放资源 步骤A.C 略过,说步骤B 读取数据的方式: A:int read():一次读取 ...
- 12Spring_AOP编程(AspectJ)_前置通知
接下里的博客会一篇一篇的讲解每一个通知.其实AOP_AspectJ的编程与传统的AOP的编程的最大的区别就是写一个Aspect 支持多个Advice和多个PointCut .而且我们写AOP_Aspc ...
- 08Spring_Spring和junit测试集成
第一步: 在项目导入 spring-test-3.2.0.RELEASE.jar 第二步: 编写测试类
- 混合语言编程:启用CLR(公共语言运行时编译)让C#调用C++
前言 关于混合C#和C++的编程方式,本人之前写过一篇博客(参见混合语言编程:C#使用原生的Directx和OpenGL),在之前的博客中,介绍了在C#的Winform和WPF下使用原生的Direct ...
- WP老杨解迷:如何获得更多的应用评价和解读内容刷新
Windows Phone的市场评论功能研究的时间比较长,只是这一功能,估计就能写一篇论文,我曾搞过多款评论数超高的游戏,其中<少林塔防>是重量级的作品,至今稳坐最高评分第一把交椅,如果不 ...
- MySQL基础 - mysql命令行客户端
在Linux系统当中,mysql作为一个客户端命令程序,在很大程度上连接数据库都是使用mysql,因此很有必要熟悉mysql命令行的使用. 这里假设数据库用户为icebug,密码为icebug_pas ...
- 动态执行SQL语句
在实际制作过程中,需要动态的拼接SQL语句然后执行.具体代码如下: declare @columnName varchar(20),@tempName varchar(20) select @temp ...
- 对SharePreference的封装
今天需要用到SharePreference来保存一些设置参数,因为要用到很多次 所以对它进行了封装: public class PrefUtils { public static void putBo ...
- Android 6.0 SDK 找不到HttpClient的解决方法
一.情况描述 在eclipse或Android Studio开发时(笔者目前只用过Android Studio),设置Android SDK的编译版本为23时,且使用了httpClient相关类的库项 ...