Problem Brief
Is Possible
FULLTIMEOA
Consider a pair of integers, (a, b). The following operations can be performed on (a, b) in any order, zero or more times.
- (a, b) → (a + b, b)
- (a, b) → (a, a + b)
Return a string that denotes whether or not (a, b) can be converted to (c, d) by performing the operation zero or more times.
Function Description
Complete the function isPossible in the editor.
isPossible has the following parameter(s):
int a: first value in (a, b)int b: second value in (a, b)int c: first value in (c, d)int d: second value in (c, d)
Returns
string: "Yes" if possible, otherwise "No"
1Example 1
Input
a = 1, b = 1, c = 5, d = 2
Output
"Yes"
Explanation
Perform the operation (1, 1 + 1) to get (1, 2), perform the operation (1 + 2, 2) to get (3, 2), and perform the operation (3+2, 2) to get (5, 2). Alternatively, the first operation could be (1+1, 1) to get (2, 1) and so on. The diagram below demonstrates the example that represents the pairs as Cartesian coordinates:
[Graph with points (1,1), (1,2), and (3,2) plotted, leading to the "Goal" point (5,2)]
Constraints
Limits and guarantees your solution can rely on.
1 <= a, b, c, d <= 1000