303634: CF702D. Road to Post Office
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Road to Post Office
题意翻译
【题目描述】 起点与终点相隔4500米。现Charley 需要从起点骑车到终点。但是,他有个习惯,沿途需要有人陪伴,即以相同的速度, 与另外一个人一起骑。而当他遇到以更快的速度骑车的人时,他会以相应的速度跟上这个更快的人。先给定所有与Charley 同路的人各自的速度与出发时间,问Charley 以这种方式跟人,骑完4500米需要多少时间。得出的结果若是小数,则向上取整。 【输入】 输入若干组数据,每组数据第一行n(1≤n≤10000),n为0,表示输入结束,接着输入n行数据,每行2个数据,表示速度v和出发时间t,如果t<0,表示陪伴人提早出发了。 【输出】 输出对应若干行数据,每行输出1个数,表示最快到达的时间。题目描述
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.输入输出格式
输入格式
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.
输出格式
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