CSES - Datatähti 2021 loppu - Results
Submission details
Task:Suuremmat
Sender:Nanohenry
Submission time:2021-01-23 16:19:56 +0200
Language:C++11
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED35
#2ACCEPTED65
Test results
testverdicttimegroup
#1ACCEPTED0.01 s1, 2details
#2ACCEPTED0.01 s2details

Code

#include <iostream>

using namespace std;

int64_t n, t, c, b;

inline int64_t s1(int64_t x) {
	x++;
	c = 0;
	while (x >= 10) {
		x /= 10;
		c++;
	}
	b = x;
	x = 0;
	for (int64_t i = 0; i <= c; i++) {
		x *= 10;
		x += b;
	}
	return x;
}

inline int64_t s2(int64_t x) {
	x++;
	c = 0;
	while (x >= 10) {
		x /= 10;
		c++;
	}
	b = x == 9? 1 : x + 1;
	x = 0;
	for (int64_t i = 0; i <= c; i++) {
		x *= 10;
		x += b;
	}
	return x;
}

int main() {
	cin >> n;
	for (int64_t i = 0; i < n; i++) {
		cin >> t;
		int64_t s = s1(t);
		if (s > t) {
			cout << s << endl;
		} else {
			cout << s2(t) << endl;
		}
	}
}

Test details

Test 1

Group: 1, 2

Verdict: ACCEPTED

input
1000
1
2
3
4
...

correct output
2
3
4
5
6
...

user output
2
3
4
5
6
...

Test 2

Group: 2

Verdict: ACCEPTED

input
1000
735425311146082632
756615631808964686
466489470801941584
100417544394053220
...

correct output
777777777777777777
777777777777777777
555555555555555555
111111111111111111
555555555555555555
...

user output
777777777777777777
777777777777777777
555555555555555555
111111111111111111
555555555555555555
...