Patrick and Shopping

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

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

Input

第一行的输入包括三个整数 d1, d2, d3 (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. UICollectionView笔记2

    WWDC 2012 Session笔记——219 Advanced Collection Views and Building Custom Layouts 这是博主的WWDC2012笔记系列中的一篇 ...

  2. Mac 颜色取值

    command+shift+4  截图,我靠,我以前不知道 系统自带数码测色计, 选择显示十六位制 command+L 锁定 command+shift+c 复制 简直太方便

  3. Android list加载图片工具类

    总体思路 Handler + looper + message 核心类 package com.base.imagechoose.util; import android.graphics.Bitma ...

  4. 【MFC】将当前的日期转化为1970年开始的秒计数

    CTime time1 = CTime::GetCurrentTime(); int nTSeconds = time1.GetTime(); CTime time2(,,,,,); nTSecond ...

  5. UML中类图(Class Diagram)的关系整理

    什么是UML类图? 类图显示了一组类.接口.协作以及他们之间的关系.在UML中问题域最终要被逐步转化,通过类来建模,通过编程语言构建这些类从而实现系统.类加上他们之间的关系就构成了类图,类图中还可以包 ...

  6. MAC MAMP install yaf

    Yaf doesn't support PHP 5.6! You may see this: Warning: PHP Startup: yaf: Unable to initialize modul ...

  7. PHP重定向的三个方法

    js的重定向方法:location.href=目标 url(如 https:www.baidu.com); php的重定向方法: header("location: https:www.ba ...

  8. PHP:php遍历数组 foreach echo() list()总结

    php中可以用来遍历数组的方法有很多,如有:foreach语句.list().each(),这几个也是主要的方法,现总结如下: foreach语句遍历数组 foreach语句用于循环遍历数组,每进行一 ...

  9. OpenLayers项目分析——(一)项目介绍

    OpenLayers 是由MetaCarta公司开发的,用于WebGIS客户端的JavaScript包,目前的最高版本是2.7 V,通过BSD License 发行.它实现访问地理空间数据的方法都符合 ...

  10. 制作带复选框的ListView控件

    实现效果: 知识运用   ListView控件的GridLines //设置是否在ListView控件中显示网格线 public bool GridLines{get;set} 和CheckBoxes ...