CSES - Datatähti 2018 alku - Results
Submission details
Task:Kyselyt
Sender:Jace
Submission time:2017-10-04 02:54:33 +0300
Language:Python3
Status:READY
Result:37
Feedback
groupverdictscore
#1ACCEPTED12
#2ACCEPTED25
#30
Test results
testverdicttimegroup
#1ACCEPTED0.09 s1details
#2ACCEPTED0.09 s2details
#30.17 s3details

Code

from math import log, ceil

queries = []

count = int(input())
for _ in range(count):
    queries.append(int(input()))

#for i in range(4):
#    print(len([_ for _ in range(1, 10000) if ceil(log(_, 10)) == i]))
#    print(ceil(log(10**i + 1, 10))*10**(i+1)*0.9 / (i+1))
#    print(ceil(log(10**i + 1, 10))*10**(i+1)*0.9)
#    print()

def group(x):
    i = 0
    c = 0
    while c + ceil(log(10**i + 1, 10))*10**(i+1)*0.9 < x:
        c += ceil(log(10**i + 1, 10))*10**(i+1)*0.9
        i += 1
    return i, c

#cc = ""
#for i in range(1, 25000):
#    cc += str(i)


for query in queries:
    #print('Q', query)
    #print('C', cc[query-1])
    #print('G', group(query))
    if query < 10:
        print(query)
    else:
        l, s = group(query)
        s += 1
        
        #print(query - s,
        #      (query - s)//(l+1),
        #      10**l + (query - s)//(l+1),
        #      (query - s) % (l+1))
        print(str(int(10**l + (query - s)//(l+1)))[int((query - s) % (l+1))])
        #print('?')

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:

input
1000
672274832941907421
260504693279721732
646999966092970935
100853063389774434
...

correct output
7
2
2
0
9
...

user output
4
2
3
6
9
...
Truncated