QUESTION

Text
Image


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) \rightarrow(a+b, b)$ - $(a, b) \rightarrow(a, a+b)$ Return a string that denotes whether or not $(a, b)$ can be converted to to $(c, d)$ by by performing zero or more of the operations specified above. Example $(a, b)=(1,1)$ $(c, d)=(5,2)$ 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 representing the pairs as Cartesian coordinates:


Function Description Complete the function isPossible in the editor below. 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: str: Return 'Yes' if $(a, b)$ can be converted to ( $c, d)$ by performing zero or more of the operations specified above, or 'No' if not. Constraints - $1 \leq a, b, c, d \leq 1000$

Language: Java

Public Answer

J91S1X The First Answerer