CF876A.Trip For Meal
入门
通过率:0%
时间限制:1.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 c meters.
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.
小熊维尼非常喜欢蜂蜜!因此他决定去拜访他的朋友们。维尼有三位最好的朋友:兔子、猫头鹰和屹耳,他们各自住在自己的房子里。每对房子之间都有一条蜿蜒的小路相连。兔子家与猫头鹰家之间的路径长度为 a 米,兔子家与屹耳家之间的路径长度为 b 米,猫头鹰家与屹耳家之间的路径长度为 c 米。
为了享受生活并欢快地歌唱,小熊维尼每天需要进餐 n 次。此时他正位于兔子家,并已进行了第一次进餐。每次当维尼当前所在的那位朋友家中蜂蜜即将耗尽时,他便会离开该房子。如果维尼尚未完成所需次数的进餐,他就会从该房子出发,前往其余两位朋友中的一位家中。为此,他将从当前房子出发的两条相邻路径中任选一条,沿该路径抵达另一端的房子并拜访那位朋友。你可以假设:当维尼正在某位朋友家中进餐时,其余朋友家中的蜂蜜储备会得到恢复(很可能是他们去补货了)。
小熊维尼不喜欢体力活动。他希望在完成 n 次进餐的同时,使所行走的总路程最短。请帮助他求出这一最短距离。
输入格式
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.
第一行包含一个整数 n(1≤n≤100)—— 访问次数。
第二行包含一个整数 a(1≤a≤100)—— 小兔子家与猫头鹰家之间的距离。
第三行包含一个整数 b(1≤b≤100)—— 小兔子家与屹耳家之间的距离。
第四行包含一个整数 c(1≤c≤100)—— 猫头鹰家与屹耳家之间的距离。
输出格式
Output one number — minimum distance in meters Winnie must go through to have a meal n times.
输出一个数字——小熊维尼为吃 n 次饭所需经过的最小距离(单位:米)。
输入输出样例
输入#1
3 2 3 1
输出#1
3
输入#2
1 2 3 5
输出#2
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.
在第一个测试用例中,小熊维尼的最优路径如下:首先在兔子家进餐,然后在猫头鹰家进餐,最后在屹耳家进餐。因此他经过的总距离为 2 + 1 = 3。
在第二个测试用例中,小熊维尼仅在兔子家进餐,这就足够了。因此他完全不需要步行。
输入解题思路,AI测评打分。不知道怎么写?