| Task: | Numerot |
| Sender: | jnalanko |
| Submission time: | 2020-10-17 01:59:52 +0300 |
| Language: | C++ (C++17) |
| Status: | READY |
| Result: | 12 |
| group | verdict | score |
|---|---|---|
| #1 | ACCEPTED | 12 |
| #2 | WRONG ANSWER | 0 |
| #3 | WRONG ANSWER | 0 |
| test | verdict | time | group | |
|---|---|---|---|---|
| #1 | ACCEPTED | 0.03 s | 1, 2, 3 | details |
| #2 | WRONG ANSWER | 0.03 s | 2, 3 | details |
| #3 | RUNTIME ERROR | 0.03 s | 3 | details |
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";
}
}Test details
Test 1
Group: 1, 2, 3
Verdict: ACCEPTED
| input |
|---|
| 1000 1 2 3 4 ... |
| correct output |
|---|
| 1 10 11 20 22 ... |
| user output |
|---|
| 1 10 11 20 22 ... Truncated |
Test 2
Group: 2, 3
Verdict: WRONG ANSWER
| input |
|---|
| 1000 224995 413660 249827 2125 ... |
| correct output |
|---|
| 1731724 3216040 1940719 14585 532612 ... |
| user output |
|---|
| -1 -1 -1 14585 532612 ... Truncated |
Test 3
Group: 3
Verdict: RUNTIME ERROR
| input |
|---|
| 1000 627887018110416188 785474884983906653 653772166720939773 784335285960673683 ... |
| correct output |
|---|
| 5530371754830260284 6918696171534226533 5757755627065159149 6908439780325129803 3223801064342340738 ... |
| user output |
|---|
| (empty) |
