summaryrefslogtreecommitdiffstats
path: root/01-algorithmic_toolbox/02-greedy_algorithms/01-change/change.cpp
blob: 612066b6ba05555587c8e5281e830aadb582c86f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>

int get_change(int n)
{
    int N = 0;

    while(n >= 10) {
        n -= 10;
        N += 1;
    }
    while(n >= 5) {
        n -= 5;
        N += 1;
    }
    while(n >= 1) {
        n -= 1;
        N += 1;
    }

    return N;
}

int main() {
  int n;
  std::cin >> n;
  std::cout << get_change(n) << '\n';
}