#P4752. Covered Path

Covered Path

Covered Path

题面翻译

题目描述:

PP 用车载计算机测量出,汽车在某段路径的起点速度为 v1v_1 米/秒,终点速度为 v2v_2 米/秒,我们知道这段路需要 tt 秒通过。假设每秒内的速度恒定,每秒之间速度的差值不超过 dd 。求路径段的最大可能长度,单位为米。

输入格式:

第一行包含两个整数 v1v_1v2v_21v1,v21001\le v_1,v_2\le 100),第二行包含两个整数 ttdd2t1002\le t\le 1000d100\le d\le 10),保证一定有解。

输出格式:

仅有一个数,表示以米为单位的路径最大可能长度。

样例解释:

在样例1中,小 PP 的车的速度序列如下:5、7、8、6。因此,总路径是 5+7+8+6=265+7+8+6=265+7+8+6=265+7+8+6=26 米。

题目描述

The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals v1 v_{1} meters per second, and in the end it is v2 v_{2} meters per second. We know that this section of the route took exactly t t seconds to pass.

Assuming that at each of the seconds the speed is constant, and between seconds the speed can change at most by d d meters per second in absolute value (i.e., the difference in the speed of any two adjacent seconds does not exceed d d in absolute value), find the maximum possible length of the path section in meters.

输入格式

The first line contains two integers v1 v_{1} and v2 v_{2} ( 1<=v1,v2<=100 1<=v_{1},v_{2}<=100 ) — the speeds in meters per second at the beginning of the segment and at the end of the segment, respectively.

The second line contains two integers t t ( 2<=t<=100 2<=t<=100 ) — the time when the car moves along the segment in seconds, d d (0<=d<=10) (0<=d<=10) — the maximum value of the speed change between adjacent seconds.

It is guaranteed that there is a way to complete the segment so that:

  • the speed in the first second equals v1 v_{1} ,
  • the speed in the last second equals v2 v_{2} ,
  • the absolute value of difference of speeds between any two adjacent seconds doesn't exceed d d .

输出格式

Print the maximum possible length of the path segment in meters.

样例 #1

样例输入 #1

5 6
4 2

样例输出 #1

26

样例 #2

样例输入 #2

10 10
10 0

样例输出 #2

100

提示

In the first sample the sequence of speeds of Polycarpus' car can look as follows: 5, 7, 8, 6. Thus, the total path is 5+7+8+6=26 5+7+8+6=26 meters.

In the second sample, as d=0 d=0 , the car covers the whole segment at constant speed v=10 v=10 . In t=10 t=10 seconds it covers the distance of 100 meters.