Advertisement
Josif_tepe

Untitled

Mar 12th, 2024
746
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.     int n;
  6.     cin >> n;
  7.    
  8.     int res = 2e9;
  9.     for(int i = 0; i <= n; i++) {
  10.         int d = 5 * i;
  11.         if(d >= n) {
  12.             if(res > i) {
  13.                 res = i;
  14.             }
  15.            
  16.         }
  17.        
  18.         if(d <= n) {
  19.            
  20.            
  21.             int s = n - d;
  22.             s /= 10;
  23.            
  24.             if((n - d) % 10 != 0) {
  25.                 s++;
  26.             }
  27.             if(i >= s) {
  28.                 if(res > i + s) {
  29.                     res = i + s;
  30.                 }
  31.             }
  32.         }
  33.        
  34.     }
  35.     cout << res << endl;
  36.     return 0;
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement