codeforce_876A_水

博客围绕维尼吃蜜展开,维尼有三个朋友,各住一处且两两间有路径。他每天需用餐n次,初始在兔子家。他要在蜜快吃完时去其他朋友家,且希望走最小距离完成n次用餐。博客给出输入输出要求及示例,求解最小行程距离。

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.

Input
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
Output one number — minimum distance in meters Winnie must go through to have a meal n times.

Sample Input
Input
3
2
3
1
Output
3
Input
1
2
3
5
Output
0
Hint
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.
题意:维尼吃蜜,可以到伊尔和兔子家,还有他自己家都有蜜,当他离开家后家里的蜜就会被补充满,求他要吃多少蜜要走的最小距离
解 00000

#include<bits/stdc++.h>
using  namespace std;
int main()
{
   int n,a,b,c,s1,s2;
   while(cin>>n>>a>>b>>c)
   {
       int cnt=1,ans=0;
       if(cnt==n)
       {
           puts("0");
           continue;
       }
       s1=min(a,b);
       cnt++;
       ans+=s1;
       if(cnt==n)
       {
            cout<<ans<<endl;
            continue;
       }
        s2=min(s1,c);
        cnt++;
        ans+=s2;
       cout<<ans+(n-cnt)*s2<<endl;

   }
    return 0;
}
### Codeforces 题目难度分布及评级标准 Codeforces 的题目难度范围广泛,涵盖了从新手到专家级别的各种挑战[^1]。该平台通过细致的分层机制来区分不同难度等级的问题,使得每位参赛者都能找到适合自己平的任务。 #### 评分体系概述 Codeforces 使用基于积分制的评价系统,其中每道题都有一个对应的分数(rating),用于表示其相对难易程度。较低的 rating 表明这是一道较为简单的题目;而较高的 rating 则意味着更高的复杂性和解决难度。通常情况下: - **简单题**:Rating 小于等于 1200 分 - **中等偏难题**:Rating 范围大约在 1600 至 2000 分之间 - **困难题**:Rating 大于等于 2400 分 这些数值并不是固定的界限,而是根据社区反馈以及比赛实际情况调整的结果。 #### Divisions 和 Contest Types 为了更好地适应不同程度的学习者和技术爱好者的需求,Codeforces 提供了多种类型的竞赛活动,比如 Division 1, Division 2, Division 3 及 Division 4 等不同类型的比赛[^2]。每个 division 对应着不同的最低准入门槛——即参与者应该具备的基础能力或经验平。例如,在更高级别的比赛中会遇到更多高难度的问题。 #### 技术领域覆盖 平台上发布的题目不仅限于单一的技术方向,还涉及到多个计算机科学的重要分支,如贪心算法、动态规划、图论等领域。这种多样性有助于全面锻炼编程技巧并促进跨学科思维的发展。 ```python # 示例 Python 代码片段展示如何获取某场比赛的信息 import requests def get_contest_info(contest_id): url = f"https://codeforces.com/api/contest.standings?contestId={contest_id}&from=1&count=1" response = requests.get(url).json() if 'result' not in response or 'problems' not in response['result']: return None problems = response['result']['problems'] for problem in problems: print(f"{problem['index']}: {problem['name']} - Rating: {problem.get('rating', 'N/A')}") get_contest_info(1669) ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值