CSES - Datatähti 2018 alku - Results
Submission details
Task:Kyselyt
Sender:valokoodari
Submission time:2017-10-06 08:48:05 +0300
Language:C++
Status:READY
Result:100
Feedback
groupverdictscore
#1ACCEPTED12
#2ACCEPTED25
#3ACCEPTED63
Test results
testverdicttimegroup
#1ACCEPTED0.04 s1details
#2ACCEPTED0.05 s2details
#3ACCEPTED0.07 s3details

Code

#include <bits/stdc++.h>
using namespace std;
long long int func1(int a) {
long long int b = 10;
for (int i = 1; i < a; i++) {
b += 9 * (long long int)pow(10, i) * (i + 1);
}
return b;
}
int main() {
int q;
cin >> q;
long long int k[q];
for (int i = 0; i < q; i++) {
cin >> k[i];
}
for (int i = 0; i < q; i++) {
int a = 1;
if (k[i] < 10) {
cout << k[i] << endl;
} else {
while (true) {
if (k[i] < func1(a)) {
long long int l = k[i]-func1(a-1);
long long int m = l%a;
string num = to_string(((l-m)/a) + (long long int)pow(10, a-1));
cout << num[m] << endl;
break;
}
a++;
}
}
}
}

Test details

Test 1

Group: 1

Verdict: ACCEPTED

input
1000
582
214
723
273
...

correct output
0
1
7
7
6
...

user output
0
1
7
7
6
...
Truncated

Test 2

Group: 2

Verdict: ACCEPTED

input
1000
615664
916441
627600
279508
...

correct output
1
2
3
2
2
...

user output
1
2
3
2
2
...
Truncated

Test 3

Group: 3

Verdict: ACCEPTED

input
1000
672274832941907421
260504693279721732
646999966092970935
100853063389774434
...

correct output
7
2
2
0
9
...

user output
7
2
2
0
9
...
Truncated