結果

問題 No.1458 Segment Function
ユーザー 👑 KazunKazun
提出日時 2021-04-14 01:51:07
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 651 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 87,108 KB
実行使用メモリ 79,428 KB
最終ジャッジ日時 2023-09-12 15:35:14
合計ジャッジ時間 7,563 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,216 KB
testcase_01 AC 72 ms
71,456 KB
testcase_02 AC 72 ms
71,424 KB
testcase_03 AC 70 ms
71,424 KB
testcase_04 AC 71 ms
71,552 KB
testcase_05 AC 69 ms
71,432 KB
testcase_06 AC 71 ms
71,452 KB
testcase_07 AC 69 ms
71,332 KB
testcase_08 AC 110 ms
77,112 KB
testcase_09 AC 109 ms
77,392 KB
testcase_10 AC 110 ms
77,580 KB
testcase_11 AC 108 ms
77,760 KB
testcase_12 AC 116 ms
77,560 KB
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 73 ms
71,332 KB
testcase_24 WA -
testcase_25 AC 70 ms
71,520 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 RE -
testcase_32 AC 112 ms
77,576 KB
testcase_33 AC 110 ms
77,672 KB
testcase_34 AC 112 ms
77,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def f(x):
    if x==0:
        return 6
    elif x==1:
        return 2
    elif x==2:
        return 5
    elif x==3:
        return 5
    elif x==4:
        return 4
    elif x==5:
        return 5
    elif x==6:
        return 6
    elif x==7:
        return 4
    elif x==8:
        return 7
    elif x==9:
        return 6
    elif x>=10:
        return f(x//10)+f(x%10)
    else:
        return 1+f(-x)

def g(S):
    if S[0]=="-":
        S=S[1:]
        X=1
    else:
        X=0

    for s in S:
        X+=f(int(s))
    return X

P,N=input().split()
N=int(N)

P=g(P)
N-=1

while N:
    N-=1
    P=f(P)
    if 4<=P<=6:
        break

print(P)
0