Advertisement
Promi_38

cf 1255A

Oct 1st, 2021
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.39 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int t;
  8.     scanf("%d", &t);
  9.    
  10.     while(t--)
  11.     {
  12.         long long a, b;
  13.         cin >> a >> b;
  14.        
  15.         long long cnt = 0, x = abs(a-b);
  16.         while(x >= 5)
  17.         {
  18.             cnt += x / 5;
  19.             x %= 5;
  20.         }
  21.         while(x >= 2)
  22.         {
  23.             cnt += x / 2;
  24.             x %= 2;
  25.         }
  26.         while(x >= 1)
  27.         {
  28.             cnt += x / 1;
  29.             x %= 1;
  30.         }
  31.        
  32.         cout << cnt << endl;
  33.     }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement