Advertisement
Josif_tepe

Untitled

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