Kangaroo Meeting Point

Two kangaroos jump along a number line at the same time, and you need to know whether they will ever land on the same spot. The first starts at x1 and jumps v1 units each time; the second starts at x2 and jumps v2 units each time. Return YES if their positions match after the same number of jumps, otherwise return NO.

Примеры

Ввод
0, 3, 4, 2
Вывод
"YES"
Ввод
0, 2, 5, 3
Вывод
"NO"
Ввод
21, 6, 47, 3
Вывод
"NO"

Нужно реализовать

def number_line_jumps(x1: int, v1: int, x2: int, v2: int) -> str:

Теги

math
PostgreSQLv16

Här visas resultatet av din kod

Visible tests
1
Input
0, 3, 4, 2
Expected"YES"
2
Input
0, 2, 5, 3
Expected"NO"
3
Input
21, 6, 47, 3
Expected"NO"
4
Input
0, 2, 0, 2
Expected"YES"
5
Input
43, 2, 70, 2
Expected"NO"
6
Input
0, 3, 4, 3
Expected"NO"
Focus radio
Paused · SomaFM · Fluid