CF1113A.Sasha and His Trip
入门
通过率:0%
时间限制:1.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Sasha is a very happy guy, that's why he is always on the move. There are n cities in the country where Sasha lives. They are all located on one straight line, and for convenience, they are numbered from 1 to n in increasing order. The distance between any two adjacent cities is equal to 1 kilometer. Since all roads in the country are directed, it's possible to reach the city y from the city x only if x<y.
Once Sasha decided to go on a trip around the country and to visit all n cities. He will move with the help of his car, Cheetah-2677. The tank capacity of this model is v liters, and it spends exactly 1 liter of fuel for 1 kilometer of the way. At the beginning of the journey, the tank is empty. Sasha is located in the city with the number 1 and wants to get to the city with the number n. There is a gas station in each city. In the i-th city, the price of 1 liter of fuel is i dollars. It is obvious that at any moment of time, the tank can contain at most v liters of fuel.
Sasha doesn't like to waste money, that's why he wants to know what is the minimum amount of money is needed to finish the trip if he can buy fuel in any city he wants. Help him to figure it out!
萨沙是一个非常快乐的人,因此他总是四处奔波。萨沙所在的国家共有 n 座城市。这些城市全部位于一条直线上,为方便起见,它们按从左到右的顺序编号为 1 到 n。任意两座相邻城市之间的距离均为 1 千米。由于该国所有道路均为单向,因此仅当 x<y 时,才能从城市 x 到达城市 y。
某日,萨沙决定环游全国,访问全部 n 座城市。他将驾驶自己的汽车“猎豹-2677”完成这次旅行。该车型油箱容量为 v 升,每行驶 1 千米恰好消耗 1 升燃油。旅程开始时,油箱为空。萨沙位于编号为 1 的城市,希望抵达编号为 n 的城市。每座城市均设有一座加油站;在第 i 座城市,每升燃油的价格为 i 美元。显然,在任意时刻,油箱中最多只能容纳 v 升燃油。
萨沙不喜欢浪费金钱,因此他想知道:若可在途经的任意城市购买任意数量的燃油,完成此次旅行所需的最少花费是多少?请帮助他解决这个问题!
输入格式
The first line contains two integers n and v (2≤n≤100, 1≤v≤100) — the number of cities in the country and the capacity of the tank.
第一行包含两个整数 n 和 v(2≤n≤100,1≤v≤100)—— 分别表示该国的城市数量和油箱容量。
输出格式
Print one integer — the minimum amount of money that is needed to finish the trip.
输出一个整数——完成此次旅行所需的最少金额。
输入输出样例
输入#1
4 2
输出#1
4
输入#2
7 6
输出#2
6
说明/提示
In the first example, Sasha can buy 2 liters for 2 dollars (1 dollar per liter) in the first city, drive to the second city, spend 1 liter of fuel on it, then buy 1 liter for 2 dollars in the second city and then drive to the 4-th city. Therefore, the answer is 1+1+2=4.
In the second example, the capacity of the tank allows to fill the tank completely in the first city, and drive to the last city without stops in other cities.
在第一个例子中,萨沙可以在第一座城市以 2 美元的价格购买 2 升汽油(即每升 1 美元),然后驾车前往第二座城市,在途中消耗 1 升汽油,接着在第二座城市以 2 美元的价格再购买 1 升汽油,最后驾车前往第四座城市。因此,答案为 1+1+2=4。
在第二个例子中,油箱容量允许萨沙在第一座城市将油箱加满,并且无需在其他城市停留即可直接驾车抵达最后一座城市。
输入解题思路,AI测评打分。不知道怎么写?