CSES - Datatähti 2018 alku - Results
Submission details
Task:Merkkijono
Sender:1
Submission time:2017-10-06 17:30:35 +0300
Language:Python3
Status:READY
Result:0
Feedback
groupverdictscore
#10
Test results
testverdicttime
#10.08 sdetails
#20.07 sdetails
#30.08 sdetails
#40.09 sdetails
#50.08 sdetails
#60.08 sdetails
#70.06 sdetails
#80.07 sdetails
#90.06 sdetails
#100.08 sdetails

Code

import math as m

def calc_mag_size(mag, base):
  c = 0
  for i in range(1, mag + 1):
    c += (base**i - base**(i-1)) * i
  return c

def get_mag(n, b):
  c = 0
  i = 1
  while c < n:
    c += (b**i - b**(i-1)) * i
    i += 1
  return i - 1

def locate_digit(n, b):
  magnitude = get_mag(n, b)
  n -= calc_mag_size(magnitude-1, b)
  i = b**(magnitude - 1) + m.ceil(n / magnitude) - 1
  n -= (i - b**(magnitude-1)) * magnitude
  print("n-1: " + str(n-1))
  print("i: " + str(i))
  return int(str(i)[n - 1])

q = int(input())
r = []
for i in range(0, q):
    r.append(int(input()))

for i in r:
    print(locate_digit(i, 10))

Test details

Test 1

Verdict:

input
ABABABABABABABABABABABABABABAB...

correct output
ABABABABABABABABABABABABABABAB...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 26, in <module>
    q = int(input())
ValueError: invalid literal for int() with base 10: 'ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA

Test 2

Verdict:

input
AABBAABBAABBAABBAABBAABBAABBAA...

correct output
(empty)

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 26, in <module>
    q = int(input())
ValueError: invalid literal for int() with base 10: 'AABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAABBAAB

Test 3

Verdict:

input
ABABABABABABABABABABABABABABAB...

correct output
(empty)

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 26, in <module>
    q = int(input())
ValueError: invalid literal for int() with base 10: 'ABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABABA

Test 4

Verdict:

input
BBABABBBBBAABBBABABABBBBAAABAB...

correct output
BAB

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 26, in <module>
    q = int(input())
ValueError: invalid literal for int() with base 10: 'BBABABBBBBAABBBABABABBBBAAABABAABBBBBABBAABABABAABABAABABAABBAAABBABAABAAABABAAABAABBAABBABABBABBABBAAABBBBABBABBBABBAAABBBAAAABABABAABAABBAAAAABABBABABABBABBBBAABBBABBBAABBBABAABBABBBAAABBAAAAABAABA

Test 5

Verdict:

input
ACDCBBACDBBBACAACBBDBADBAABABA...

correct output
ACDCACDADBADABACACDCADADABABCA...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 26, in <module>
    q = int(input())
ValueError: invalid literal for int() with base 10: 'ACDCBBACDBBBACAACBBDBADBAABABACACDAACADADABABCACBCBCBCADDBABCCCDCBDBACDCDCCCCACAACDBABAAADDDBAADABBBCDADAADCDBDBCBDACBABDBCBCBBCACCDDBBCDCBDCDCAADACACABADBDAADBABCDABBBBABBCAADABDABCAAABDBBBBACACBCDC

Test 6

Verdict:

input
EETFHIJOGACDHMGVFJCMETMZDEITTR...

correct output
TFHIJOGACDHMGVFJCMETMZDEIROTET...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 26, in <module>
    q = int(input())
ValueError: invalid literal for int() with base 10: 'EETFHIJOGACDHMGVFJCMETMZDEITTROTETBSAQREWKXSUQRTJSTMAYKWXMHMMWBRVLIVCGSTGYQJUYYSGWQSDQMHWXNSYPPOIQTIHWMUYRDINAAIUORGPINGWFDQAMBUNDKSQPRPWNQJYZMTJGPTFPCZZPGIVYURCHDHEMWVZDLEOKVCDKWSILOJXDERMWOHLUYRDZN

Test 7

Verdict:

input
GOONLAHLYPRFCZKIKSJWAWWYJJPCDB...

correct output
GNLAHLYPRFCZKIKSJWAYPCDNWYMRCE...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 26, in <module>
    q = int(input())
ValueError: invalid literal for int() with base 10: 'GOONLAHLYPRFCZKIKSJWAWWYJJPCDBBNWYMRCEHGRBLZOOZXEHVPDFXVCTWAWJTYSQHCYPQVKJOZRQUBAYVQHIWGJBXFKJIDDSAWEXWQGBTNMKQHKTXAAZVKKYTKFYGGFWXOVSHMDPQJOHCVVIFGVMSKWFIAUZSFLDFTFDJYRQXCDLFVHCWHCTPYWYDEESTZVZMRYUW

Test 8

Verdict:

input
PISHWMOTCDDZFRMYMOMYDYYGJZIQHS...

correct output
PISHWMOTCZFRMYMOMYDGJZIQHSVAOK...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 26, in <module>
    q = int(input())
ValueError: invalid literal for int() with base 10: 'PISHWMOTCDDZFRMYMOMYDYYGJZIQHSPPVAOKCVWVNOFCVIDUKPNVKSWMAGEUUZDKABCGEOWKFFWVLKINEWFSBODTECTFDVIMLZDVJQVNHIYAAXOLWCDLYDTNRBWMPTLWWFMSXTVEZPGCPOMOHXULJNZLVIPQANEVHKKZBUVTDDGSBVRFCXSTOTMQJUVBPHWVAXNIPOR

Test 9

Verdict:

input
QUVVTPXAMWWODFXRONJODPGBTCISGM...

correct output
QUTPXAMODFXRONJODPGBTCISGMVRBW...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 26, in <module>
    q = int(input())
ValueError: invalid literal for int() with base 10: 'QUVVTPXAMWWODFXRONJODPGBTCISGMVWWRBWRZHKKLAFTQABFHFWMFNTZPSAWUDLABCXURSULRAOGBABUWOMDITAGQOYPUEZEPRGWOOAQFLHGQTHZNUUFSCNDCRXVNXMROXDXEYYJJRHZPESKGUMPLOYLKVNDLSNUYFHAUOQKUFKFQDVGNOOLEMDCVPQYEAXMBJIWWX

Test 10

Verdict:

input
POXHAHYEZTLYNFSLABODMRNKDSKROZ...

correct output
POXHAHYEZTLYNFSLABODMRNKDSKROZ...

user output
(empty)

Error:
Traceback (most recent call last):
  File "input/code.py", line 26, in <module>
    q = int(input())
ValueError: invalid literal for int() with base 10: 'POXHAHYEZTLYNFSLABODMRNKDSKROZWJCEHBGGTIQBYGWGOLUPTJKMXGIBMBJRGQUGDKEKFTZNOYGRTOPJPLEHWXCPOOUHPPIQNJZUFRHPLTYBULNLCLYEXSASENZOSLVZGKBLNRWDNZDWGRLVJKCPKSXJWRZCXOHPTDQDWPEORPCRUZDGMMTOOKTQBCBZIXNTQSMPD