結果

問題 No.1458 Segment Function
ユーザー nasubi24nasubi24
提出日時 2021-03-31 21:47:48
言語 PyPy3
(7.3.15)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 957 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 75,648 KB
最終ジャッジ日時 2024-04-20 17:38:02
合計ジャッジ時間 3,462 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,096 KB
testcase_01 AC 39 ms
51,712 KB
testcase_02 AC 65 ms
67,328 KB
testcase_03 AC 64 ms
67,456 KB
testcase_04 AC 66 ms
67,456 KB
testcase_05 AC 66 ms
67,968 KB
testcase_06 AC 65 ms
67,712 KB
testcase_07 AC 65 ms
67,456 KB
testcase_08 AC 52 ms
65,792 KB
testcase_09 AC 52 ms
65,920 KB
testcase_10 AC 52 ms
66,560 KB
testcase_11 AC 54 ms
65,920 KB
testcase_12 AC 52 ms
65,536 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 69 ms
67,584 KB
testcase_24 AC 42 ms
53,504 KB
testcase_25 AC 41 ms
52,096 KB
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 40 ms
52,096 KB
testcase_29 AC 42 ms
53,120 KB
testcase_30 AC 42 ms
53,120 KB
testcase_31 RE -
testcase_32 AC 53 ms
65,664 KB
testcase_33 AC 52 ms
65,408 KB
testcase_34 AC 52 ms
65,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p,n=input().split()
ans=0
if n=="0":
    print(p)
else:
    if p[0]=="-":
        ans+=1
        p=p[1:]
    num=[6,2,5,5,4,5,6,4,7,6]
    memo=[]
    for i in range(10):
        for j in range(len(p)):
            ans+=num[int(p[j])]
        memo.append(ans)
        p=str(ans)
        ans=0
    if int(n)<=10:
        print(memo[int(n)-1])
    else:
        seen=[False]*(2*10**6)
        memo2=[]
        for i in range(2*10**6):
            for j in range(len(p)):
                ans+=num[int(p[j])]
            if seen[ans]==True:
                for j in range(len(memo2)):
                    if memo2[j]==ans:
                        k=j
                        break
                break
            memo2.append(ans)
            seen[ans]=True
            p=str(ans)
            ans=0
        if int(n)-10<len(memo2):
            print(memo2[int(n)-10])
        else:
            memo2=memo2[k:]
            print(memo2[(int(n)-10)%len(memo2)])
0