#P4752. Covered Path
Covered Path
Covered Path
题面翻译
题目描述:
小 用车载计算机测量出,汽车在某段路径的起点速度为 米/秒,终点速度为 米/秒,我们知道这段路需要 秒通过。假设每秒内的速度恒定,每秒之间速度的差值不超过 。求路径段的最大可能长度,单位为米。
输入格式:
第一行包含两个整数 和 (),第二行包含两个整数 和 (,),保证一定有解。
输出格式:
仅有一个数,表示以米为单位的路径最大可能长度。
样例解释:
在样例1中,小 的车的速度序列如下:5、7、8、6。因此,总路径是 米。
题目描述
The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals meters per second, and in the end it is meters per second. We know that this section of the route took exactly seconds to pass.
Assuming that at each of the seconds the speed is constant, and between seconds the speed can change at most by meters per second in absolute value (i.e., the difference in the speed of any two adjacent seconds does not exceed in absolute value), find the maximum possible length of the path section in meters.
输入格式
The first line contains two integers and ( ) — 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 ( ) — the time when the car moves along the segment in seconds, — 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 ,
- the speed in the last second equals ,
- the absolute value of difference of speeds between any two adjacent seconds doesn't exceed .
输出格式
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 meters.
In the second sample, as , the car covers the whole segment at constant speed . In seconds it covers the distance of 100 meters.