Untitled
unknown
python
2 years ago
648 B
6
Indexable
def f(L, x1, v1, x2, v2):
if x1 != x2 and v1 == v2 == 0:
return "NO", 0
times = []
if v1 != v2:
for k in [-1, 0, 1]:
times.append((k*L + x2 - x1)/(v1 - v2))
for k in [-1, 0, 1]:
times.append((k * L - x1 - x2) / (v1 + v2))
t_min = None
for t in times:
if t >= 0:
if t_min is None:
t_min = t
else:
if t < t_min:
t_min = t
return "YES", t_min
L, x1, v1, x2, v2 = map(int, input().split())
ans, t_min = f(L, x1, v1, x2, v2)
print(ans)
if ans == "YES":
print(t_min)Editor is loading...
Leave a Comment