Goldman SachsOA #26
Is Possible
Estimated MediumJudge-ready
Topics (AI-labelled)Bits & Math
Starting from a pair of positive integers (a,b), you may repeatedly apply (a,b)→(a+b,b) or (a,b)→(a,a+b). Determine whether the target pair of positive integers (c,d) can be obtained; zero operations are allowed.
Input
A single line containing a b c d. Original range: 1≤a,b,c,d≤1000.
Output
Output Yes if reachable, otherwise output No.
Example 1
Input:
1 1 3 2
Output:
Yes
Example 2
Input:
2 3 5 8
Output:
Yes
Example 3
Input:
1 2 2 2
Output:
No
Editorial
Loading solution…