結果

問題 No.1595 The Final Digit
ユーザー 回転
提出日時 2025-10-13 21:34:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 476 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 82,248 KB
実行使用メモリ 55,924 KB
最終ジャッジ日時 2025-10-13 21:34:26
合計ジャッジ時間 2,379 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 9 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
p,q,r,K = list(map(int,input().split()))

now = (p+q+r) % 10
A = [p,q,r]
d = defaultdict(int)
for i in range(4,K+1):
    now = (A[-1] + A[-2] + A[-3]) % 10
    A.append(now)
    if(now not in d):
        d[now] = i
    else:
        loop_len = i - d[now]
        nokori = (K - i) % loop_len
        for _ in range(nokori):
            now = (A[-1] + A[-2] + A[-3]) % 10
            A.append(now)
        print(now)
        exit()
print(now)
0