Patrick and Shopping

今天 Patrick
等待着他的朋友 Spongebob
来他家玩。为了迎接
Spongebob,Patrick
需要去他家附近的两家商店  买一些吃的。他家离第一家商店有d1米远,离第二家商店有d2米远。还有,两家商店之间的距离是d3,帮Patrick计算去两家商店然后回家的最短距离。

Patrick 永远从他家出发,他不介意重复经过同一个地点或者同一条路,唯一的目标就是:最小化经过两间商店然后回家的距离。

Input

第一行的输入包括三个整数 d1d2d3 (1 ≤ d1, d2, d3 ≤ 108)

  • d1 是 Patrick
    的家离第一间商店的距离;
  • d2 是 Patrick 的家离第二 间商店的距离;
  • d3 是两间商店的距离 .

Output

输出经过两家商店然后回家的最短距离。

Sample Input

10    20    30
1     1     5
		

Sample Output

60
4

Hint

第一个样例是先经过第一间,再经过第二间,再回家

水题,就三个数,怎么都能找。

#include<stdio.h>
int min(int a,int b)
{
if(a<b) return a;
else
return b;
}
int main()
{
int d1,d2,d3;
scanf("%d%d%d",&d1,&d2,&d3);
int sum=0;
int d=min(d1,d2);
sum+=d; int d4=min(d3,d1+d2);
sum+=d4;
if(d==d1)
sum+=min(d2,d3+d1);
else
{
sum+=min(d1,d3+d2);
}
printf("%d\n",sum);
return 0;
}

Patrick and Shopping的更多相关文章

  1. 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 ...

  2. 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 ...

  3. CodeForces 599A Patrick and Shopping

    水题.每种情况取最小值即可. #include<cstdio> #include<cstring> #include<cmath> #include<algo ...

  4. [cf 599A]Patrick and Shopping

    傻逼题,但是我还是wa了一发. #include <iostream> using namespace std; int main() { long long a,b,c,Ans=0x7f ...

  5. Codeforces Round #332 (Div. 2)

    水 A - Patrick and Shopping #include <bits/stdc++.h> using namespace std; int main(void) { int ...

  6. Shopping(山东省第一届ACM省赛)

    Shopping Time Limit: 1000MS Memory limit: 65536K 题目描述 Saya and Kudo go shopping together.You can ass ...

  7. 【CodeForces 599A】D - 特别水的题4- Patrick and Shopping

    Description  meter long road between his house and the first shop and a d2 meter long road between h ...

  8. sdutoj 2154 Shopping

    http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2154 Shopping Time Limit: ...

  9. Shopping(SPFA+DFS HDU3768)

    Shopping Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

随机推荐

  1. 傻瓜式的go modules的讲解和代码,及gomod能不能引入另一个gomod和gomod的use of internal package xxxx not allowed

    一 国内关于gomod的文章,哪怕是使用了百度 -csdn,依然全是理论,虽然golang的使用者大多是大神但是也有像我这样的的弱鸡是不是? 所以,我就写个傻瓜式教程了. github地址:https ...

  2. cucumber的hooks

    引用链接:https://github.com/cucumber/cucumber/wiki/Hooks Hooks Cucumber provides a number of hooks which ...

  3. Js常见算法实现汇总

    /*去重*/ <script> function delRepeat(arr){ var newArray=new Array(); var len=arr.length; for(var ...

  4. ps使用

    1.图片剪裁 1.按快捷键M(矩形选择工具)-> 选中要扣出的图片(按shift可正方形)->按快捷键C(剪裁工具)->双击鼠标选中区域,剪裁成功. 2.选中psd中的图标 1.按快 ...

  5. css最佳实践(reset.css)

    html, body, div, span, object, iframe,h1, h2, h3, h4, h5, h6, p, blockquote, pre,abbr, address, cite ...

  6. js学习的一些想法(有一些来自网络)

    javascript开发最佳实践学习 1.给变量和函数命名--变量名和函数名尽量简短 好的变量命名应该是简短易懂的,还有需要避免的陷阱就是在命名中将数值与功能结合. 匈牙利命名法就是一个不错的选择,也 ...

  7. WPF样式学习:ToolBar的使用

    隐藏拖动把手: 设置ToolBar属性 ToolBarTray.IsLocked="True",可以达到隐藏拖动把手的目的 private void ToolBar_Loaded( ...

  8. 【转】Nginx跳转任意Http请求到Https

    网站买了证书,绿条,多霸气! 那么自然得拦截http的访问方式了. 拦截http,301到https 各种Google,最后在Nginx官网找到例子,配置很简单,如下: server { listen ...

  9. nginx 升级为最新版 nginx -1.12.0

    标签:nginx 公司目前使用的nginx版本比较低(nginx-1.0.12),请网络安全公司做了一下“远程安全评估”,发现有下列漏洞: nginx URI处理安全限制绕过漏洞(CVE-2013-4 ...

  10. hihocoder 1093 SPFA算法

    题目链接:http://hihocoder.com/problemset/problem/1093 , 最短路的SPFA算法. 由于点的限制(10w),只能用邻接表.今天也学了一种邻接表的写法,感觉挺 ...