| 17 | using namespace std; |
| 18 | |
| 19 | int main() |
| 20 | { |
| 21 | long long int x1,v1,x2,v2; |
| 22 | cin>>x1>>v1>>x2>>v2; |
| 23 | |
| 24 | // checking initial conditions |
| 25 | if((x1>x2 && v1>v2) || (x2>x1 && v2>v1)) |
| 26 | cout<<"NO"<<endl; |
| 27 | else if(x1==x2 && v1==v2) |
| 28 | cout<<"YES"<<endl; |
| 29 | else if(v1==v2) |
| 30 | cout<<"NO"<<endl; |
| 31 | else |
| 32 | { |
| 33 | // finding the 'y' that can satisfy x,v |
| 34 | long int y = abs((x2-x1)/(v1-v2)); |
| 35 | // check if the 'y' satisfies the given x,v of kangaroos |
| 36 | if(x1+v1*y == x2+v2*y) |
| 37 | cout<<"YES"<<endl; |
| 38 | else |
| 39 | cout<<"NO"<<endl; |
| 40 | } |
| 41 | |
| 42 | return 0; |
| 43 | } |
| 44 | |
| 45 | // Sample test-case: |
| 46 | // I/P: 0 3 4 2 |