結果

問題 No.1458 Segment Function
ユーザー nasubi24
提出日時 2021-03-31 21:43:58
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 686 bytes
コンパイル時間 563 ms
コンパイル使用メモリ 82,192 KB
実行使用メモリ 75,264 KB
最終ジャッジ日時 2024-12-15 16:58:26
合計ジャッジ時間 3,653 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 2 RE * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

p,n=input().split()
ans=0
if p[0]=="-":
    ans+=1
    p=p[1:]
num=[6,2,5,5,4,5,6,4,7,6]
if n=="0":
    print(p)
else:
    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:
                break
            memo2.append(ans)
            seen[ans]=True
            p=str(ans)
            ans=0
        print(memo2[(int(n)-10)%len(memo2)])
0