結果

問題 No.1595 The Final Digit
コンテスト
ユーザー AEn
提出日時 2022-05-16 10:53:57
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 65 ms / 2,000 ms
+ 964µs
コード長 398 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 234 ms
コンパイル使用メモリ 95,976 KB
実行使用メモリ 79,104 KB
最終ジャッジ日時 2026-08-26 18:01:25
合計ジャッジ時間 3,054 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

p, q, r, K = map(int, input().split())
n = set()
o = []
p %= 10; q %= 10; r %= 10
n.add((p, q, r))
o.append([p, q, r])
for i in range(K-3):
    p, q, r = q, r, (p+q+r)%10
    if (p, q, r) in n:
        idx = o.index([p, q, r])
        p = (K-3-idx)%(len(o)-idx)
        pp, qq, rr = o[idx+p]
        print(rr)
        exit()
    else:
        n.add((p, q, r))
        o.append([p, q, r])
print(r)

0