Question
Mr. Pr and Ms. Ad are at a and b respectively on an infinite number line. Mr. Pr wants to meet Ms. Ad. Mr. Pr
Mr. Pr and Ms. Ad are at a and b respectively on an infinite number line. Mr. Pr wants to meet Ms. Ad.
Mr. Pr can choose to move c or d units in 1 second. If Mr. Pr moves c units then Ms. Ad will move d units and vice versa. (Both of them always moved in positive x-direction).
You have to determine if Mr. Pr can meet with Ms. Ad after some integral amount of time, given that Mr. Pr chooses optimally. Note that meeting after a fractional amount of time does not count.
Constraints
1a,b,c,d109
Input Format
Four space separated integers, a, b, c, and d.
Output Format
Output a single line containing "YES" if Mr. Pr meets with Ms. Ad, otherwise "NO".
Sample #1
Input
3 4 1 2
Output
YES
Explanation
Mr. Pr will move 2 units in the first second
and Ms. Ad moves 1 unit simultaneously
and they meet.
Sample #2
Input
10 20 3 7
Output
NO
Explanation
It is impossible to meet
(fractional time is not allowed)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started