Олимпиадный тренинг

Задача 38219. Ring


Задача

Темы: Целые числа
Two cars are moving along a ring road of length L in opposite directions. They start from one point and travel with constant speeds v1 and v2, respectively. It is required to determine how far apart they will be at time T.

Input
The input is 4 natural numbers L, v1, v2, T, separated by a space. All numbers do not exceed 100.

Imprint
Print the distance between cars at time T – the length of the shortest of the two arcs of the road between cars.
 
# Input Output
1 10 1 2 1 3
2 10 2 3 2 0