Untitled

 avatar
unknown
c_cpp
4 years ago
477 B
3
Indexable
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int memo[1000006];

int main()
{
    int n;
    cin >> n;
    int najmal = 0;
    while(n > 0) {
        int max_cifra = 0;
        int tmp = n;
        while(tmp > 0) {
            max_cifra = max(max_cifra, tmp % 10);
            tmp /= 10;
        }
        n -= max_cifra;
        najmal++;
    }
    cout << najmal << endl;
    return 0;
}
// 20 --> 18 --> 10 --> 9 --> 0
// 21 --> 19 --> 10

Editor is loading...