CSES - Putka Open 2020 – 3/5 - Results
Submission details
Task:Numerot
Sender:jnalanko
Submission time:2020-10-17 01:59:42 +0300
Language:C++ (C++17)
Status:COMPILE ERROR

Compiler report

input/code.cpp:6:10: fatal error: stdlib_printing.hh: No such file or directory
 #include "stdlib_printing.hh"
          ^~~~~~~~~~~~~~~~~~~~
compilation terminated.

Code

#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <cmath>
#include "stdlib_printing.hh"

using namespace std;
typedef long long LL;

LL inf = 1e18;

int main(int argc, char** argv){

    // Precalc
    vector<LL> f(1e6+1,inf);
    f[0] = 0;
    for(LL x = 1; x <= 1e6; x++){
        LL y = x;
        while(y != 0){
            LL d = y % 10; y /= 10;
            if(x - d >= 0) f[x] = min(f[x], f[x-d]+1);
        }
    }
    vector<LL> answers(1e6+1,inf);
    for(LL s = 1e6; s >= 1; s--){
        answers[f[s]] = s;
    }

    // Solve
    LL t; cin >> t;
    while(t--){
        LL n; cin >> n;
        if(answers[n] == inf) cout << -1 << "\n";
        else cout << answers[n] << "\n";
    }

}