CSES - Putka Open 2020 – 3/5 - Results
Submission details
Task:Numerot
Sender:Metabolix
Submission time:2020-10-16 20:36:12 +0300
Language:C++17
Status:READY
Result:12
Feedback
groupverdictscore
#1ACCEPTED12
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.03 s1, 2, 3details
#20.03 s2, 3details
#30.03 s3details

Code

#include <iostream>
#include <algorithm>

int f[1000002];

int ff(int i) {
	int min = 0xffffff;
	for (int j = i; j; j /= 10) {
		int num = j % 10;
		if (num) {
			int k = f[i - num] + 1;
			if (k < min) {
				min = k;
			}
		}
	}
	return min;
}

int main() {
	for (int i = 1; i <= 1000000; ++i) {
		f[i] = ff(i);
	}

	int t;
	std::cin >> t;
	for (int i = 0; i < t; ++i) {
		long x;
		std::cin >> x;
		if (x > 1000000) return 1;
		std::cout << (std::lower_bound(f, f + 1000000, x) - f) << '\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
...

Test 2

Group: 2, 3

Verdict:

input
1000
224995
413660
249827
2125
...

correct output
1731724
3216040
1940719
14585
532612
...

user output
1000000
1000000
1000000
14585
532612
...

Test 3

Group: 3

Verdict:

input
1000
627887018110416188
785474884983906653
653772166720939773
784335285960673683
...

correct output
5530371754830260284
6918696171534226533
5757755627065159149
6908439780325129803
3223801064342340738
...

user output
(empty)