← 返回 nvidia 的题目列表Reaching Points
类型:online_judge
On a 2D plane, start at (sx, sy). In one move, you may perform either operation:
(x, y) -> (x + y, y)
(x, y) -> (x, x + y)
Given four positive integers sx, sy, tx, and ty, determine whether it is possible to reach exactly (tx, ty) from (sx, sy).
Example 1:
Input: sx = 1, sy = 1, tx = 3, ty = 5
Output: true
Explanation: (1,1) -> (1,2) -> (3,2) -> (3,5)
Example 2:
Input: sx = 1, sy = 1, tx = 2, ty = 2
Output: false
Constraints:
1 <= sx, sy, tx, ty <= 10^9
Avoid simulating moves in the forward direction.
Example
Input
1 1 3 5
Output
true