交通信号灯AI (CI翻译)
A car moves from point A to point B at speed $*v*$ meters per second. The action takes place on the X-axis. At the distance $*d*$ meters from A there are traffic lights. Starting from time 0, for the first $*g*$ seconds the green light is on, then for the following $*r*$ seconds the red light is on, then again the green light is on for the $*g*$ seconds, and so on.
汽车以每秒 $*v*$ 米的速度从点 A 行驶到点 B。整个过程发生在 X 轴上。距离 A 点 $*d*$ 米处有一组交通信号灯。从时刻 0 开始,绿灯持续 $*g*$ 秒,接着红灯持续 $*r*$ 秒,然后绿灯再持续 $*g*$ 秒,如此循环。AI (CI翻译)
The car can be instantly accelerated from $0$ to $*v*$ and vice versa, can instantly slow down from the $*v*$ to $0$. Consider that it passes the traffic lights at the green light instantly. If the car approaches the traffic lights at the moment when the red light has just turned on, it doesn't have time to pass it. But if it approaches the traffic lights at the moment when the green light has just turned on, it can move. The car leaves point A at the time 0.
汽车可以瞬间从速度 0 加速到 $*v*$,也可以瞬间从 $*v*$ 减速到 0。假设汽车可以在绿灯亮着时瞬间通过信号灯。如果汽车恰好在红灯刚亮起时到达信号灯,就来不及通过;但如果恰好在绿灯刚亮起时到达,就可以通过。汽车在时刻 0 从点 A 出发。AI (CI翻译)
What is the minimum time for the car to get from point A to point B without breaking the traffic rules?
在不违反交通规则的情况下,汽车从点 A 到点 B 的最短时间是多少?AI (CI翻译)
Input
输入格式
AI (CI翻译)The first line contains integers $*l*$, $*d*$, $*v*$, $*g*$, $*r*$ ($1 ≤ *l*, *d*, *v*, *g*, *r* ≤ 1000, *d* < *l*$) — the distance between A and B (in meters), the distance from A to the traffic lights, car's speed, the duration of green light and the duration of red light.
第一行包含整数 $*l*$、$*d*$、$*v*$、$*g*$、$*r*$($1 ≤ *l*, *d*, *v*, *g*, *r* ≤ 1000, *d*$ < $*l*$),分别表示 A、B 两点之间的距离(米)、A 点到交通信号灯的距离(米)、汽车的速度、绿灯持续时间和红灯持续时间。AI (CI翻译)
Output
输出格式
AI (CI翻译)Output a single number — the minimum time that the car needs to get from point A to point B. Your output must have relative or absolute error less than $10^{ - 6}$.
输出一个数,即汽车从点 A 到点 B 所需的最短时间。答案的相对误差或绝对误差必须小于 $10^{ - 6}$。AI (CI翻译)
样例
2 1 3 4 5
0.66666667
5 4 3 1 1
2.33333333
题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(gpt-6.1-sol),如有出入请以原文为准。