Task: | Numerot |
Sender: | Mahtimursu |
Submission time: | 2020-10-16 19:11:40 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 12 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 12 |
#2 | TIME LIMIT EXCEEDED | 0 |
#3 | TIME LIMIT EXCEEDED | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.05 s | 1, 2, 3 | details |
#2 | TIME LIMIT EXCEEDED | -- | 2, 3 | details |
#3 | TIME LIMIT EXCEEDED | -- | 3 | details |
Code
#include <iostream> #include <bits/stdc++.h> typedef long long ll; #define M 1000000007 using namespace std; int table[1000001]; int zero(int num) { //cout << num << "\n"; if (num == 0) return 0; if (num < 0) return 1e9; if (table[num]) { return table[num]; } int m = 1e9; int t = num; while (t > 0) { int d = t % 10; t /= 10; if (d == 0) continue; m = min(zero(num - d) + 1, m); } table[num] = m; return m; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 1; i <= 1e6; ++i) { zero(i); } for (int i = 0; i < n; ++i) { int x; cin >> x; for (int j = 1; j <= 1e6; ++j) { if (table[j] == x) { cout << j << endl; break; } } } return 0; }
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: TIME LIMIT EXCEEDED
input |
---|
1000 224995 413660 249827 2125 ... |
correct output |
---|
1731724 3216040 1940719 14585 532612 ... |
user output |
---|
(empty) |
Test 3
Group: 3
Verdict: TIME LIMIT EXCEEDED
input |
---|
1000 627887018110416188 785474884983906653 653772166720939773 784335285960673683 ... |
correct output |
---|
5530371754830260284 6918696171534226533 5757755627065159149 6908439780325129803 3223801064342340738 ... |
user output |
---|
(empty) |