codeforces Round #441 A Trip For Meal【思路/模拟】
1 second
512 megabytes
standard input
standard output
Winnie-the-Pooh likes honey very much! That is why he decided to visit his friends. Winnie has got three best friends: Rabbit, Owl and Eeyore, each of them lives in his own house. There are winding paths between each pair of houses. The length of a path between Rabbit's and Owl's houses is a meters, between Rabbit's and Eeyore's house is b meters, between Owl's and Eeyore's house is cmeters.
For enjoying his life and singing merry songs Winnie-the-Pooh should have a meal n times a day. Now he is in the Rabbit's house and has a meal for the first time. Each time when in the friend's house where Winnie is now the supply of honey is about to end, Winnie leaves that house. If Winnie has not had a meal the required amount of times, he comes out from the house and goes to someone else of his two friends. For this he chooses one of two adjacent paths, arrives to the house on the other end and visits his friend. You may assume that when Winnie is eating in one of his friend's house, the supply of honey in other friend's houses recover (most probably, they go to the supply store).
Winnie-the-Pooh does not like physical activity. He wants to have a meal n times, traveling minimum possible distance. Help him to find this distance.
First line contains an integer n (1 ≤ n ≤ 100) — number of visits.
Second line contains an integer a (1 ≤ a ≤ 100) — distance between Rabbit's and Owl's houses.
Third line contains an integer b (1 ≤ b ≤ 100) — distance between Rabbit's and Eeyore's houses.
Fourth line contains an integer c (1 ≤ c ≤ 100) — distance between Owl's and Eeyore's houses.
Output one number — minimum distance in meters Winnie must go through to have a meal n times.
3
2
3
1
3
1
2
3
5
0
In the first test case the optimal path for Winnie is the following: first have a meal in Rabbit's house, then in Owl's house, then in Eeyore's house. Thus he will pass the distance 2 + 1 = 3.
In the second test case Winnie has a meal in Rabbit's house and that is for him. So he doesn't have to walk anywhere at all.
【题意】:一个三角形,给出一个数n和三条边长,要求到达三个点总共n次(不要求每个点都到)。起点固定在R,求走的最短距离。
【分析】:在最短路上反复横跳(?)。因为反正可以回头。
【代码】:
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
int n,a,b,c;
scanf("%d%d%d%d",&n,&a,&b,&c);
if(n==)
printf("%d\n", );
if(n==)
printf("%d\n",min(a,b) );
if(n>)
printf("%d\n",min(a,b) + min(min(a,b), c)* (n-) ); return ;
}
codeforces Round #441 A Trip For Meal【思路/模拟】的更多相关文章
- Codeforces Round #441 D. Sorting the Coins(模拟)
http://codeforces.com/contest/876/problem/D 题意:题意真是难懂,就是给一串序列,第i次操作会在p[x](1<=x<=i)这些位置放上硬币,然后从 ...
- Codeforces Round #441 (Div. 2)【A、B、C、D】
Codeforces Round #441 (Div. 2) codeforces 876 A. Trip For Meal(水题) 题意:R.O.E三点互连,给出任意两点间距离,你在R点,每次只能去 ...
- Codeforces Round #441 (Div. 2)
Codeforces Round #441 (Div. 2) A. Trip For Meal 题目描述:给出\(3\)个点,以及任意两个点之间的距离,求从\(1\)个点出发,再走\(n-1\)个点的 ...
- [日常] Codeforces Round #441 Div.2 实况
上次打了一发 Round #440 Div.2 结果被垃圾交互器卡掉 $200$ Rating后心情复杂... 然后立了个 Round #441 要翻上蓝的flag QAQ 晚饭回来就开始搞事情, 大 ...
- Codeforces Round #441 (Div. 2, by Moscow Team Olympiad)
A. Trip For Meal 题目链接:http://codeforces.com/contest/876/problem/A 题目意思:现在三个点1,2,3,1-2的路程是a,1-3的路程是b, ...
- Codeforces Round #441 Div. 2 A B C D
题目链接 A. Trip for Meal 题意 三个点之间两两有路径,分别长为\(a,b,c\),现在从第一个点出发,走\(n-1\)条边,问总路径最小值. 思路 记起始点相邻的边为\(a,b\), ...
- ACM-ICPC (10/16) Codeforces Round #441 (Div. 2, by Moscow Team Olympiad)
A. Trip For Meal Winnie-the-Pooh likes honey very much! That is why he decided to visit his friends. ...
- Codeforces Round #284 (Div. 2)A B C 模拟 数学
A. Watching a movie time limit per test 1 second memory limit per test 256 megabytes input standard ...
- Codeforces Round #285 (Div. 2) A B C 模拟 stl 拓扑排序
A. Contest time limit per test 1 second memory limit per test 256 megabytes input standard input out ...
随机推荐
- Windows 64下elasticsearch-1.7.1集群 安装、启动、停止
elasticsearch-1.7.1 (es Windows 64) 安装.启动.停止的详细记录 https://blog.csdn.net/qq_27093465/article/details/ ...
- water 解题报告
water 题目描述 有一块矩形土地被划分成\(n\times m\)个正方形小块.这些小块高低不平,每一小块都有自己的高度.水流可以由任意一块地流向周围四个方向的四块地中,但是不能直接流入对角相连的 ...
- 简单瞎搞题(bitset的操作)
链接:https://www.nowcoder.com/acm/contest/132/C来源:牛客网 题目 一共有 n个数,第 i 个数是 xi xi 可以取 [li , ri] 中任意的一个值. ...
- 解决“并非来自 Chrome 网上应用店。”
Chrome谷歌浏览器已停用不支持的扩展程序解决方法 第一种方法:(亲测有效) 1.首先把需要安装的第三方插件,后缀.crx 改成 .rar,然后解压,得到一个文件夹 2.再打开chrome://ex ...
- js实现日历
有这样一个普通的日历需求 第一反应就是找插件,结果找到了,但是改起来非常麻烦,然后查下实现的原理,发现原来很简单,于是自己实现了一个. 首先分析一下这个组件,每页显示的是 当前月的所有日期及所占据的行 ...
- 图论---图的m-点着色判定问题(回溯法--迭代式)
转自 图的m着色问题 图的m-着色判定问题——给定无向连通图G和m种不同的颜色.用这些颜色为图G的各顶点着色,每个顶点着一种颜色,是否有一种着色法使G中任意相邻的2个顶点着不同颜色? 图的m-着色优化 ...
- spring boot修改内置容器tomcat的服务端口
方式一 在spring boot的web 工程中,可以使用内置的web container.有时需要修改服务端口,可以通过配置类和@Configuration注解来完成. // MyConfigura ...
- [POJ1845&POJ1061]扩展欧几里得应用两例
扩展欧几里得是用于求解不定方程.线性同余方程和乘法逆元的常用算法. 下面是代码: function Euclid(a,b:int64;var x,y:int64):int64; var t:int64 ...
- autoKeras入门
测试本地mnist数据集 图片只用500张,450张做train与50张test, 代码如下: # conding:utf-8 import os os.environ[' import numpy ...
- 不能使用联机NuGet 程序包
打开菜单栏>>工具>>选项>>NuGet 程序包管理器>>选择程序包源 勾选上nuget.org,即可使用联机的Nuget包