#C2900. Three Racers Convergence
Three Racers Convergence
Three Racers Convergence
You are given the starting positions and speeds of three racers. The racers move in a straight line. At time t (where t is a non‐negative integer), the position of the i-th racer is given by:
\(a_i + v_i \times t\)
Your task is to determine whether there exists a time t ≥ 0 such that all three racers are at exactly the same position. Print YES
if such a time exists, otherwise print NO
.
Note: When all three racers have the same speed, it is assumed that they will eventually be at the same position.
inputFormat
The input consists of a single line containing six space‐separated integers:
- a1, a2, a3: the starting positions of the three racers.
- v1, v2, v3: the speeds of the three racers.
Mathematically, the position of the i-th racer at time \(t\) is \(a_i + v_i \times t\). All values are integers.
outputFormat
Output a single line containing either YES
if the three racers will ever meet at the same position at the same time, or NO
if they will not.
1 2 3 1 2 3
NO