Advertisement
allia

деление 30

Dec 8th, 2020
719
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. long long ostatok(long long a, long long b)
  8. {
  9.    while (a > 0)
  10.     {
  11.       a -= b;
  12.       if (a < b)
  13.        break;
  14.     }
  15.  
  16.   a = abs(a);
  17.   return a;
  18. }
  19.  
  20. long long delenie (long long a, long long b)
  21. {
  22.   long long znach = 0;
  23.  
  24.   while (a > 0)
  25.   {
  26.     znach++;
  27.     a -= b;
  28.     if (a < b)
  29.      break;
  30.   }
  31.   return znach;
  32. }
  33.  
  34. int main()
  35. {
  36.   long long a, b;
  37.   cin >> a >> b;
  38.  
  39.   if (a == b)
  40.    cout << 1 << " " << 0;
  41.    else if (a < b)
  42.     cout << 0 << " " << ostatok(a, b);
  43.     else cout << delenie(a, b) << " " << ostatok(a, b);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement