A9780 | Covered Path
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
The on-board computer on Polycarp's car measured that the car speed at the beginning of some section of the path equals $v_{1}$ meters per second, and in the end it is $v_{2}$ meters per second. We know that this section of the route took exactly $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$ meters per second in absolute value (i.e., the difference in the speed of any two adjacent seconds does not exceed $d$ in absolute value), find the maximum possible length of the path section in meters.
Assuming that at each of the seconds the speed is constant, and between seconds the speed can change at most by $d$ meters per second in absolute value (i.e., the difference in the speed of any two adjacent seconds does not exceed $d$ in absolute value), find the maximum possible length of the path section in meters.
输入格式
The first line contains two integers $v_{1}$ and $v_{2}$ ( $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$ ( $2<=t<=100$ ) — the time when the car moves along the segment in seconds, $d$ $(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 $v_{1}$ ,
- the speed in the last second equals $v_{2}$ ,
- the absolute value of difference of speeds between any two adjacent seconds doesn't exceed $d$ .
The second line contains two integers $t$ ( $2<=t<=100$ ) — the time when the car moves along the segment in seconds, $d$ $(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 $v_{1}$ ,
- the speed in the last second equals $v_{2}$ ,
- the absolute value of difference of speeds between any two adjacent seconds doesn't exceed $d$ .
输出格式
Print the maximum possible length of the path segment in meters.
输入输出样例
输入 #1
5 6 4 2
输出 #1
26
输入 #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$ 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.
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.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted