Task: | Numerot |
Sender: | Olli |
Submission time: | 2020-10-17 10:26:29 +0300 |
Language: | C++ (C++11) |
Status: | READY |
Result: | 25 |
group | verdict | score |
---|---|---|
#1 | ACCEPTED | 12 |
#2 | ACCEPTED | 13 |
#3 | RUNTIME ERROR | 0 |
test | verdict | time | group | |
---|---|---|---|---|
#1 | ACCEPTED | 0.21 s | 1, 2, 3 | details |
#2 | ACCEPTED | 0.21 s | 2, 3 | details |
#3 | RUNTIME ERROR | 0.21 s | 3 | details |
Code
#include <iostream> #include <fstream> #include <vector> #include <algorithm> #include <queue> #include <stack> using namespace std; typedef long long ll; typedef long double ld; const int N = 1e7; const ll INF = 1e18; ll f[N]; ll mi[N]; int main() { iostream::sync_with_stdio(false); cin.tie(0); // ofstream out; // out.open("output.txt"); for(int i = 1; i < N; ++i) { f[i] = INF; ll j = i; while(j > 0) { f[i] = min(f[i], f[i - j%10] + 1); j /= 10; } } for(int i = 1; i < N; ++i) { if(mi[f[i]] == 0) { mi[f[i]] = i; } } /* for(int i = 1; i <= 1e5; ++i) { out << i << " " << f[i] << " " << (ld) i/f[i] << "\n"; } */ int t; cin >> t; while(t > 0) { --t; int x; cin >> x; cout << mi[x] << "\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: ACCEPTED
input |
---|
1000 224995 413660 249827 2125 ... |
correct output |
---|
1731724 3216040 1940719 14585 532612 ... |
user output |
---|
1731724 3216040 1940719 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) |