A10523 | Road to Post Office
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Vasiliy has a car and he wants to get from home to the post office. The distance which he needs to pass equals to $d$ kilometers.
Vasiliy's car is not new — it breaks after driven every $k$ kilometers and Vasiliy needs $t$ seconds to repair it. After repairing his car Vasiliy can drive again (but after $k$ kilometers it will break again, and so on). In the beginning of the trip the car is just from repair station.
To drive one kilometer on car Vasiliy spends $a$ seconds, to walk one kilometer on foot he needs $b$ seconds ( $a<b$ ).
Your task is to find minimal time after which Vasiliy will be able to reach the post office. Consider that in every moment of time Vasiliy can left his car and start to go on foot.
Vasiliy's car is not new — it breaks after driven every $k$ kilometers and Vasiliy needs $t$ seconds to repair it. After repairing his car Vasiliy can drive again (but after $k$ kilometers it will break again, and so on). In the beginning of the trip the car is just from repair station.
To drive one kilometer on car Vasiliy spends $a$ seconds, to walk one kilometer on foot he needs $b$ seconds ( $a<b$ ).
Your task is to find minimal time after which Vasiliy will be able to reach the post office. Consider that in every moment of time Vasiliy can left his car and start to go on foot.
输入格式
The first line contains 5 positive integers $d,k,a,b,t$ ( $1<=d<=10^{12}$ ; $1<=k,a,b,t<=10^{6}$ ; $a<b$ ), where:
- $d$ — the distance from home to the post office;
- $k$ — the distance, which car is able to drive before breaking;
- $a$ — the time, which Vasiliy spends to drive 1 kilometer on his car;
- $b$ — the time, which Vasiliy spends to walk 1 kilometer on foot;
- $t$ — the time, which Vasiliy spends to repair his car.
- $d$ — the distance from home to the post office;
- $k$ — the distance, which car is able to drive before breaking;
- $a$ — the time, which Vasiliy spends to drive 1 kilometer on his car;
- $b$ — the time, which Vasiliy spends to walk 1 kilometer on foot;
- $t$ — the time, which Vasiliy spends to repair his car.
输出格式
Print the minimal time after which Vasiliy will be able to reach the post office.
输入输出样例
输入 #1
5 2 1 4 10
输出 #1
14
输入 #2
5 2 1 4 5
输出 #2
13
In the first example Vasiliy needs to drive the first 2 kilometers on the car (in 2 seconds) and then to walk on foot 3 kilometers (in 12 seconds). So the answer equals to 14 seconds.
In the second example Vasiliy needs to drive the first 2 kilometers on the car (in 2 seconds), then repair his car (in 5 seconds) and drive 2 kilometers more on the car (in 2 seconds). After that he needs to walk on foot 1 kilometer (in 4 seconds). So the answer equals to 13 seconds.
In the second example Vasiliy needs to drive the first 2 kilometers on the car (in 2 seconds), then repair his car (in 5 seconds) and drive 2 kilometers more on the car (in 2 seconds). After that he needs to walk on foot 1 kilometer (in 4 seconds). So the answer equals to 13 seconds.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted