結果

問題 No.1458 Segment Function
ユーザー AEnAEn
提出日時 2022-06-01 14:42:51
言語 PyPy3
(7.3.13)
結果
RE  
実行時間 -
コード長 772 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 81,692 KB
実行使用メモリ 67,040 KB
最終ジャッジ日時 2023-10-21 00:50:29
合計ジャッジ時間 3,258 ms
ジャッジサーバーID
(参考情報)
judge10 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,448 KB
testcase_01 AC 34 ms
53,444 KB
testcase_02 AC 35 ms
53,444 KB
testcase_03 AC 36 ms
53,444 KB
testcase_04 AC 36 ms
53,444 KB
testcase_05 AC 34 ms
53,444 KB
testcase_06 AC 35 ms
53,444 KB
testcase_07 AC 35 ms
53,444 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 36 ms
53,800 KB
testcase_24 RE -
testcase_25 WA -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 37 ms
53,456 KB
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

P, N = map(int, input().split())
import sys
sys.setrecursionlimit(10**9)
def f(x):
    if x==0 or x==6 or x==9:
        return 6
    elif x==1:
        return 2
    elif x==2 or x==3 or x==5:
        return 5
    elif x==4 or x==7:
        return 4
    elif x == 8:
        return 7
    elif x >= 10:
        return f(x//10)+f(x%10)
    else:
        return 1 + f(-x)

n = [list() for _ in range(10)]
for i in range(10):
    x = i
    n[i].append(x)
    while 1:
        y = f(x)
        if y == x:
            break
        else:
            n[i].append(y)
            x = y

for i in range(min(N, 5*10**6)):
    if len(str(P)) == 1:
        id = i
        break
    P = f(P)
else:
    print(P)
    exit()
left = N - id
print(n[P][i] if N-id<=(len(n[P])-1) else n[P][-1])
0