Advertisement
SergeyPGUTI

9.2(ТАКСИ)

Mar 6th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. int main() {
  7.  
  8.     int start1,start2,a1,a2,price;
  9.     cin>>start1;
  10.     cin>>a1;
  11.     cin>>start2;
  12.     cin>>a2;
  13.     price=start1;
  14.     while(start1<start2)
  15.     {
  16.         start1+=a1;
  17.         if (start1>=start2)
  18.         {
  19.             price=start2;
  20.             break;
  21.         }
  22.  
  23.         start2-=a2;
  24.         if (start1>=start2)
  25.         {
  26.             price=start1;
  27.             break;
  28.         }
  29.  
  30.     }
  31.     cout<<price;
  32.  
  33.  
  34.     return 0;
  35.  
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement