AtCoder Regular Contest 007

Submission #1112578

Source codeソースコード

s = input()
if s[0] == '0':
    s = '1' + s

l = len(s)
sep = l
for i in range(1, l):
    if s[i] != '0':
        sep = i
        break

a = []
a.append(int(s[0:sep]))
s = s[sep:l]
l = len(s)
if l == 0:
    print(a[0], 1)
    exit()

if a[0] >= int(s):
    b = int(s)
    sa = str(a[0])
    la = len(sa)
    lb = len(s)
    if la > lb and sa[0:lb] == s[0:lb]:
        print(a[0], 1)
        exit()

    while a[0] >= b:
        b *= 10

    print(a[0], b - a[0])
    exit()

def check(s, t):
    if s[0] == '0' or t[0] == '0':
        return False

    ls = len(s)
    lt = len(t)
    l = min(ls, lt)
    if s[0:l] == t[0:l]:
        return True
    else:
        return False

for i in range(1, l):
    b = [a[0]]
    b.append(int(s[0:i]))
    r = b[1] - b[0]
    if r <= 0:
        continue

    t = s[i:l]
    while True:
        b.append(b[-1] + r)
        u = str(b[-1])
        if not check(t, u):
            break

        lt = len(t)
        lu = len(u)
        if lt <= lu:
            print(b[0], r)
            exit()

        t = t[lu:lt]

print(a[0], int(s) - a[0])

Submission

Task問題 D - 破れた宿題
User nameユーザ名 mu
Created time投稿日時
Language言語 Python3 (3.4.3)
Status状態 AC
Score得点 100
Source lengthソースコード長 1149 Byte
File nameファイル名
Exec time実行時間 30 ms
Memory usageメモリ使用量 3192 KB

Test case

Set

Set name Score得点 / Max score Cases
level1 25 / 25 lv1/a_00_sample_01.txt,lv1/a_00_sample_02.txt,lv1/a_01_min_0.txt,lv1/a_01_min_1.txt,lv1/a_01_min_9.txt,lv1/a_01_special_01.txt,lv1/a_01_special_02.txt,lv1/a_01_special_03.txt,lv1/a_01_special_04.txt,lv1/a_01_special_05.txt,lv1/a_01_special_06.txt,lv1/a_01_special_07.txt,lv1/a_01_special_08.txt,lv1/a_01_special_09.txt,lv1/a_01_special_10.txt,lv1/a_01_special_11.txt,lv1/a_02_rand_00.txt,lv1/a_02_rand_01.txt,lv1/a_02_rand_02.txt,lv1/a_02_rand_03.txt,lv1/a_02_rand_04.txt,lv1/a_03_rand2_00.txt,lv1/a_03_rand2_01.txt,lv1/a_03_rand2_02.txt,lv1/a_03_rand2_03.txt,lv1/a_03_rand2_04.txt,lv1/a_04_rand3_00.txt,lv1/a_04_rand3_01.txt,lv1/a_04_rand3_02.txt,lv1/a_05_rand4_00.txt,lv1/a_05_rand4_01.txt,lv1/a_05_rand4_02.txt,lv1/a_06_rand5_00.txt,lv1/a_06_rand5_01.txt,lv1/a_06_rand5_02.txt
level2 25 / 25 lv1/a_00_sample_01.txt,lv1/a_00_sample_02.txt,lv1/a_01_min_0.txt,lv1/a_01_min_1.txt,lv1/a_01_min_9.txt,lv1/a_01_special_01.txt,lv1/a_01_special_02.txt,lv1/a_01_special_03.txt,lv1/a_01_special_04.txt,lv1/a_01_special_05.txt,lv1/a_01_special_06.txt,lv1/a_01_special_07.txt,lv1/a_01_special_08.txt,lv1/a_01_special_09.txt,lv1/a_01_special_10.txt,lv1/a_01_special_11.txt,lv1/a_02_rand_00.txt,lv1/a_02_rand_01.txt,lv1/a_02_rand_02.txt,lv1/a_02_rand_03.txt,lv1/a_02_rand_04.txt,lv1/a_03_rand2_00.txt,lv1/a_03_rand2_01.txt,lv1/a_03_rand2_02.txt,lv1/a_03_rand2_03.txt,lv1/a_03_rand2_04.txt,lv1/a_04_rand3_00.txt,lv1/a_04_rand3_01.txt,lv1/a_04_rand3_02.txt,lv1/a_05_rand4_00.txt,lv1/a_05_rand4_01.txt,lv1/a_05_rand4_02.txt,lv1/a_06_rand5_00.txt,lv1/a_06_rand5_01.txt,lv1/a_06_rand5_02.txt,lv2/b_01_special_01.txt,lv2/b_01_special_02.txt,lv2/b_01_special_07.txt,lv2/b_01_special_08.txt,lv2/b_01_special_09.txt,lv2/b_02_rand_00.txt,lv2/b_02_rand_01.txt,lv2/b_02_rand_02.txt,lv2/b_03_rand2_00.txt,lv2/b_03_rand2_01.txt,lv2/b_03_rand2_02.txt,lv2/b_04_rand3_00.txt,lv2/b_04_rand3_01.txt,lv2/b_04_rand3_02.txt,lv2/b_05_rand4_00.txt,lv2/b_05_rand4_01.txt,lv2/b_05_rand4_02.txt,lv2/b_06_rand5_00.txt,lv2/b_06_rand5_01.txt,lv2/b_06_rand5_02.txt
level3 25 / 25 lv1/a_00_sample_01.txt,lv1/a_00_sample_02.txt,lv1/a_01_min_0.txt,lv1/a_01_min_1.txt,lv1/a_01_min_9.txt,lv1/a_01_special_01.txt,lv1/a_01_special_02.txt,lv1/a_01_special_03.txt,lv1/a_01_special_04.txt,lv1/a_01_special_05.txt,lv1/a_01_special_06.txt,lv1/a_01_special_07.txt,lv1/a_01_special_08.txt,lv1/a_01_special_09.txt,lv1/a_01_special_10.txt,lv1/a_01_special_11.txt,lv1/a_02_rand_00.txt,lv1/a_02_rand_01.txt,lv1/a_02_rand_02.txt,lv1/a_02_rand_03.txt,lv1/a_02_rand_04.txt,lv1/a_03_rand2_00.txt,lv1/a_03_rand2_01.txt,lv1/a_03_rand2_02.txt,lv1/a_03_rand2_03.txt,lv1/a_03_rand2_04.txt,lv1/a_04_rand3_00.txt,lv1/a_04_rand3_01.txt,lv1/a_04_rand3_02.txt,lv1/a_05_rand4_00.txt,lv1/a_05_rand4_01.txt,lv1/a_05_rand4_02.txt,lv1/a_06_rand5_00.txt,lv1/a_06_rand5_01.txt,lv1/a_06_rand5_02.txt,lv2/b_01_special_01.txt,lv2/b_01_special_02.txt,lv2/b_01_special_07.txt,lv2/b_01_special_08.txt,lv2/b_01_special_09.txt,lv2/b_02_rand_00.txt,lv2/b_02_rand_01.txt,lv2/b_02_rand_02.txt,lv2/b_03_rand2_00.txt,lv2/b_03_rand2_01.txt,lv2/b_03_rand2_02.txt,lv2/b_04_rand3_00.txt,lv2/b_04_rand3_01.txt,lv2/b_04_rand3_02.txt,lv2/b_05_rand4_00.txt,lv2/b_05_rand4_01.txt,lv2/b_05_rand4_02.txt,lv2/b_06_rand5_00.txt,lv2/b_06_rand5_01.txt,lv2/b_06_rand5_02.txt,lv3/c_00_sample_03.txt,lv3/c_00_sample_04.txt,lv3/c_00_sample_05.txt,lv3/c_01_special_01.txt,lv3/c_01_special_02.txt,lv3/c_01_special_07.txt,lv3/c_01_special_08.txt,lv3/c_01_special_09.txt,lv3/c_01_special_12.txt,lv3/c_02_rand_00.txt,lv3/c_02_rand_01.txt,lv3/c_02_rand_02.txt,lv3/c_03_rand2_00.txt,lv3/c_03_rand2_01.txt,lv3/c_03_rand2_02.txt,lv3/c_04_rand3_00.txt,lv3/c_04_rand3_01.txt,lv3/c_04_rand3_02.txt,lv3/c_05_rand4_00.txt,lv3/c_05_rand4_01.txt,lv3/c_05_rand4_02.txt,lv3/c_05_rand4_03.txt,lv3/c_05_rand4_04.txt,lv3/c_06_rand5_00.txt,lv3/c_06_rand5_01.txt,lv3/c_06_rand5_02.txt,lv3/c_06_rand5_03.txt,lv3/c_06_rand5_04.txt
level4 25 / 25 lv1/a_00_sample_01.txt,lv1/a_00_sample_02.txt,lv1/a_01_min_0.txt,lv1/a_01_min_1.txt,lv1/a_01_min_9.txt,lv1/a_01_special_01.txt,lv1/a_01_special_02.txt,lv1/a_01_special_03.txt,lv1/a_01_special_04.txt,lv1/a_01_special_05.txt,lv1/a_01_special_06.txt,lv1/a_01_special_07.txt,lv1/a_01_special_08.txt,lv1/a_01_special_09.txt,lv1/a_01_special_10.txt,lv1/a_01_special_11.txt,lv1/a_02_rand_00.txt,lv1/a_02_rand_01.txt,lv1/a_02_rand_02.txt,lv1/a_02_rand_03.txt,lv1/a_02_rand_04.txt,lv1/a_03_rand2_00.txt,lv1/a_03_rand2_01.txt,lv1/a_03_rand2_02.txt,lv1/a_03_rand2_03.txt,lv1/a_03_rand2_04.txt,lv1/a_04_rand3_00.txt,lv1/a_04_rand3_01.txt,lv1/a_04_rand3_02.txt,lv1/a_05_rand4_00.txt,lv1/a_05_rand4_01.txt,lv1/a_05_rand4_02.txt,lv1/a_06_rand5_00.txt,lv1/a_06_rand5_01.txt,lv1/a_06_rand5_02.txt,lv2/b_01_special_01.txt,lv2/b_01_special_02.txt,lv2/b_01_special_07.txt,lv2/b_01_special_08.txt,lv2/b_01_special_09.txt,lv2/b_02_rand_00.txt,lv2/b_02_rand_01.txt,lv2/b_02_rand_02.txt,lv2/b_03_rand2_00.txt,lv2/b_03_rand2_01.txt,lv2/b_03_rand2_02.txt,lv2/b_04_rand3_00.txt,lv2/b_04_rand3_01.txt,lv2/b_04_rand3_02.txt,lv2/b_05_rand4_00.txt,lv2/b_05_rand4_01.txt,lv2/b_05_rand4_02.txt,lv2/b_06_rand5_00.txt,lv2/b_06_rand5_01.txt,lv2/b_06_rand5_02.txt,lv3/c_00_sample_03.txt,lv3/c_00_sample_04.txt,lv3/c_00_sample_05.txt,lv3/c_01_special_01.txt,lv3/c_01_special_02.txt,lv3/c_01_special_07.txt,lv3/c_01_special_08.txt,lv3/c_01_special_09.txt,lv3/c_01_special_12.txt,lv3/c_02_rand_00.txt,lv3/c_02_rand_01.txt,lv3/c_02_rand_02.txt,lv3/c_03_rand2_00.txt,lv3/c_03_rand2_01.txt,lv3/c_03_rand2_02.txt,lv3/c_04_rand3_00.txt,lv3/c_04_rand3_01.txt,lv3/c_04_rand3_02.txt,lv3/c_05_rand4_00.txt,lv3/c_05_rand4_01.txt,lv3/c_05_rand4_02.txt,lv3/c_05_rand4_03.txt,lv3/c_05_rand4_04.txt,lv3/c_06_rand5_00.txt,lv3/c_06_rand5_01.txt,lv3/c_06_rand5_02.txt,lv3/c_06_rand5_03.txt,lv3/c_06_rand5_04.txt,lv4/d_01_special_02.txt,lv4/d_01_special_07.txt,lv4/d_01_special_08.txt,lv4/d_01_special_09.txt,lv4/d_01_special_12.txt,lv4/d_02_rand_00.txt,lv4/d_02_rand_01.txt,lv4/d_02_rand_02.txt,lv4/d_03_rand2_00.txt,lv4/d_03_rand2_01.txt,lv4/d_03_rand2_02.txt,lv4/d_04_rand3_00.txt,lv4/d_04_rand3_01.txt,lv4/d_04_rand3_02.txt,lv4/d_05_rand4_00.txt,lv4/d_05_rand4_01.txt,lv4/d_05_rand4_02.txt,lv4/d_05_rand4_03.txt,lv4/d_05_rand4_04.txt,lv4/d_06_rand5_00.txt,lv4/d_06_rand5_01.txt,lv4/d_06_rand5_02.txt,lv4/d_06_rand5_03.txt,lv4/d_06_rand5_04.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
lv1/a_00_sample_01.txt AC 17 ms 3188 KB
lv1/a_00_sample_02.txt AC 17 ms 3188 KB
lv1/a_01_min_0.txt AC 17 ms 3188 KB
lv1/a_01_min_1.txt AC 17 ms 3188 KB
lv1/a_01_min_9.txt AC 17 ms 3188 KB
lv1/a_01_special_01.txt AC 17 ms 3188 KB
lv1/a_01_special_02.txt AC 17 ms 3188 KB
lv1/a_01_special_03.txt AC 17 ms 3188 KB
lv1/a_01_special_04.txt AC 17 ms 3188 KB
lv1/a_01_special_05.txt AC 17 ms 3188 KB
lv1/a_01_special_06.txt AC 17 ms 3188 KB
lv1/a_01_special_07.txt AC 17 ms 3188 KB
lv1/a_01_special_08.txt AC 17 ms 3188 KB
lv1/a_01_special_09.txt AC 17 ms 3188 KB
lv1/a_01_special_10.txt AC 17 ms 3188 KB
lv1/a_01_special_11.txt AC 17 ms 3188 KB
lv1/a_02_rand_00.txt AC 17 ms 3188 KB
lv1/a_02_rand_01.txt AC 17 ms 3188 KB
lv1/a_02_rand_02.txt AC 17 ms 3188 KB
lv1/a_02_rand_03.txt AC 17 ms 3188 KB
lv1/a_02_rand_04.txt AC 17 ms 3188 KB
lv1/a_03_rand2_00.txt AC 17 ms 3188 KB
lv1/a_03_rand2_01.txt AC 17 ms 3188 KB
lv1/a_03_rand2_02.txt AC 17 ms 3188 KB
lv1/a_03_rand2_03.txt AC 17 ms 3188 KB
lv1/a_03_rand2_04.txt AC 17 ms 3188 KB
lv1/a_04_rand3_00.txt AC 17 ms 3188 KB
lv1/a_04_rand3_01.txt AC 17 ms 3188 KB
lv1/a_04_rand3_02.txt AC 17 ms 3188 KB
lv1/a_05_rand4_00.txt AC 17 ms 3188 KB
lv1/a_05_rand4_01.txt AC 17 ms 3188 KB
lv1/a_05_rand4_02.txt AC 17 ms 3188 KB
lv1/a_06_rand5_00.txt AC 17 ms 3188 KB
lv1/a_06_rand5_01.txt AC 17 ms 3188 KB
lv1/a_06_rand5_02.txt AC 17 ms 3188 KB
lv2/b_01_special_01.txt AC 17 ms 3188 KB
lv2/b_01_special_02.txt AC 17 ms 3188 KB
lv2/b_01_special_07.txt AC 17 ms 3188 KB
lv2/b_01_special_08.txt AC 17 ms 3188 KB
lv2/b_01_special_09.txt AC 17 ms 3188 KB
lv2/b_02_rand_00.txt AC 17 ms 3188 KB
lv2/b_02_rand_01.txt AC 17 ms 3188 KB
lv2/b_02_rand_02.txt AC 17 ms 3188 KB
lv2/b_03_rand2_00.txt AC 17 ms 3188 KB
lv2/b_03_rand2_01.txt AC 17 ms 3188 KB
lv2/b_03_rand2_02.txt AC 17 ms 3188 KB
lv2/b_04_rand3_00.txt AC 17 ms 3188 KB
lv2/b_04_rand3_01.txt AC 17 ms 3192 KB
lv2/b_04_rand3_02.txt AC 17 ms 3188 KB
lv2/b_05_rand4_00.txt AC 17 ms 3188 KB
lv2/b_05_rand4_01.txt AC 17 ms 3188 KB
lv2/b_05_rand4_02.txt AC 17 ms 3188 KB
lv2/b_06_rand5_00.txt AC 17 ms 3188 KB
lv2/b_06_rand5_01.txt AC 17 ms 3188 KB
lv2/b_06_rand5_02.txt AC 17 ms 3188 KB
lv3/c_00_sample_03.txt AC 17 ms 3188 KB
lv3/c_00_sample_04.txt AC 17 ms 3188 KB
lv3/c_00_sample_05.txt AC 17 ms 3188 KB
lv3/c_01_special_01.txt AC 17 ms 3188 KB
lv3/c_01_special_02.txt AC 17 ms 3188 KB
lv3/c_01_special_07.txt AC 17 ms 3188 KB
lv3/c_01_special_08.txt AC 17 ms 3192 KB
lv3/c_01_special_09.txt AC 18 ms 3188 KB
lv3/c_01_special_12.txt AC 18 ms 3188 KB
lv3/c_02_rand_00.txt AC 18 ms 3188 KB
lv3/c_02_rand_01.txt AC 18 ms 3188 KB
lv3/c_02_rand_02.txt AC 18 ms 3188 KB
lv3/c_03_rand2_00.txt AC 17 ms 3188 KB
lv3/c_03_rand2_01.txt AC 17 ms 3188 KB
lv3/c_03_rand2_02.txt AC 17 ms 3188 KB
lv3/c_04_rand3_00.txt AC 17 ms 3188 KB
lv3/c_04_rand3_01.txt AC 17 ms 3188 KB
lv3/c_04_rand3_02.txt AC 17 ms 3188 KB
lv3/c_05_rand4_00.txt AC 18 ms 3188 KB
lv3/c_05_rand4_01.txt AC 17 ms 3188 KB
lv3/c_05_rand4_02.txt AC 17 ms 3188 KB
lv3/c_05_rand4_03.txt AC 17 ms 3188 KB
lv3/c_05_rand4_04.txt AC 17 ms 3188 KB
lv3/c_06_rand5_00.txt AC 17 ms 3188 KB
lv3/c_06_rand5_01.txt AC 17 ms 3188 KB
lv3/c_06_rand5_02.txt AC 17 ms 3188 KB
lv3/c_06_rand5_03.txt AC 17 ms 3188 KB
lv3/c_06_rand5_04.txt AC 17 ms 3188 KB
lv4/d_01_special_02.txt AC 17 ms 3188 KB
lv4/d_01_special_07.txt AC 17 ms 3188 KB
lv4/d_01_special_08.txt AC 17 ms 3188 KB
lv4/d_01_special_09.txt AC 29 ms 3188 KB
lv4/d_01_special_12.txt AC 22 ms 3188 KB
lv4/d_02_rand_00.txt AC 29 ms 3188 KB
lv4/d_02_rand_01.txt AC 30 ms 3188 KB
lv4/d_02_rand_02.txt AC 29 ms 3188 KB
lv4/d_03_rand2_00.txt AC 27 ms 3188 KB
lv4/d_03_rand2_01.txt AC 19 ms 3188 KB
lv4/d_03_rand2_02.txt AC 27 ms 3188 KB
lv4/d_04_rand3_00.txt AC 27 ms 3188 KB
lv4/d_04_rand3_01.txt AC 24 ms 3192 KB
lv4/d_04_rand3_02.txt AC 22 ms 3188 KB
lv4/d_05_rand4_00.txt AC 29 ms 3188 KB
lv4/d_05_rand4_01.txt AC 21 ms 3188 KB
lv4/d_05_rand4_02.txt AC 21 ms 3188 KB
lv4/d_05_rand4_03.txt AC 29 ms 3188 KB
lv4/d_05_rand4_04.txt AC 17 ms 3188 KB
lv4/d_06_rand5_00.txt AC 18 ms 3188 KB
lv4/d_06_rand5_01.txt AC 17 ms 3188 KB
lv4/d_06_rand5_02.txt AC 20 ms 3188 KB
lv4/d_06_rand5_03.txt AC 17 ms 3192 KB
lv4/d_06_rand5_04.txt AC 22 ms 3188 KB