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. webpack webpack-dev-server报错

    Error: getaddrinfo ENOTFOUND localhost at errnoException (dns.js:28:10) at GetAddrInfoReqWrap.onlook ...

  2. SQL Server收缩数据库

    USE[master]GOALTER DATABASE CCPG_SFY SET RECOVERY SIMPLE WITH NO_WAITGOALTER DATABASE CCPG_SFY SET R ...

  3. vue-resource的使用

    之前使用axios post请求不能向后台发送数据,然后使用了vue-resource这个插件 import  Vue from 'vue' import VueResource from 'vue- ...

  4. C++ 宏定义的简单使用

    1.定义常量 #define ARRMAX 50 int arr[ARRMAX]; (这种做法不如直接用const来直接定义常量.) 2.代替模板函数或者内联函数,将函数定义成宏.执行效率很快 #de ...

  5. C#利用WebClient 两种方式下载文件(一)

    WebClient client = new WebClient(); 第一种 string URLAddress = @"http://files.cnblogs.com/x4646/tr ...

  6. cms-静态化组件

    1.要让我们的网站性能更好,那么有的东西是需要做静态化的.做静态化步骤: 1.1在web.xml中配置监听器 1.2.创建一个bean用来实现静态化 web.xml <?xml version= ...

  7. 【server 安全】更改本地安全策略及禁用部分服务以进一步增强windows server的安全性

    本地安全策略 以上内容的备份 注册表路径: System\CurrentControlSet\Control\ProductOptionsSystem\CurrentControlSet\Contro ...

  8. Windows Azure 入门 -- VS 2015部署 ASP.NET网站(项目) 与 数据库

    Windows Azure 入门 -- 部署 ASP.NET网站(项目) 与数据库 https://www.dotblogs.com.tw/mis2000lab/2015/12/24/windowsa ...

  9. 自动释放池的前世今生 ---- 深入解析 autoreleasepool

    http://draveness.me/autoreleasepool.html 关注仓库,及时获得更新:iOS-Source-Code-Analyze Follow: Draveness · Git ...

  10. 索引属性 unique指定

    比较重要的属性有: 名字 db.collection.ensureIndex({},{name:''}) 在创建索引时,mongodb会自己给索引创建默认的名字,这种名字并不好记,我们看一下mongo ...