CF534B Covered Path

题目描述

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

输入格式

第一行包含两个整数 $v_1$ 和 $v_2$ ($1\le v_1,v_2\le 100$),第二行包含两个整数 $t$ 和 $d$ ($2\le t\le 100$,$0\le d\le 10$),保证一定有解。

输出格式

仅有一个数,表示以米为单位的路径最大可能长度。 #### 样例解释: 在样例1中,小 $P$ 的车的速度序列如下:5、7、8、6。因此,总路径是 $5+7+8+6=265+7+8+6=26$ 米。

说明/提示

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 $ meters. In the second sample, as $ d=0 $ , the car covers the whole segment at constant speed $ v=10 $ . In $ t=10 $ seconds it covers the distance of 100 meters.