rengetsu

HackerRank_Kangaroo

Jun 18th, 2018
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.60 KB | None | 0 0
  1. //Kangaroo
  2. #include <iostream>
  3. using namespace std;
  4. int main()
  5. {
  6.     int x1, x2, v1, v2, ats=0;
  7.     cin >> x1 >> v1 >> x2 >> v2;
  8.     if(x1>x2)
  9.     {
  10.         while(x1>=x2)
  11.         {
  12.             if(x1==x2)
  13.             {
  14.                 ats=1;
  15.             }
  16.             x1=x1+v1;
  17.             x2=x2+v2;
  18.         }
  19.     }
  20.     else if(x2>=x1)
  21.     {
  22.         while(x2>=x1)
  23.         {
  24.             if(x1==x2)
  25.             {
  26.                 ats=1;
  27.             }
  28.             x1=x1+v1;
  29.             x2=x2+v2;
  30.         }
  31.     }
  32.     if(ats==0){cout<<"NO"<<endl;}else{cout<<"YES"<<endl;}
  33.     return 0;
  34. }
Add Comment
Please, Sign In to add comment