結果
| 問題 | No.1595 The Final Digit |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-07-09 22:34:32 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 39 ms / 2,000 ms |
| + 31µs | |
| コード長 | 560 bytes |
| 記録 | |
| コンパイル時間 | 89 ms |
| コンパイル使用メモリ | 65,120 KB |
| 実行使用メモリ | 54,884 KB |
| 最終ジャッジ日時 | 2026-10-13 23:07:28 |
| 合計ジャッジ時間 | 2,713 ms |
|
ジャッジサーバーID (参考情報) |
judge4_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 |
ソースコード
from collections import deque
p,q,r,K = map(int,input().split())
p,q,r = int(str(p)[-1]),int(str(q)[-1]),int(str(r)[-1])
check = [[[0]*10 for _ in range(10)] for _ in range(10)]
check[p][q][r] = 3
memo = [p,q,r]
count = 3
l = deque([p,q,r])
while count < K:
count += 1
num = sum(l)
num = int(str(num)[-1])
l.popleft()
l.append(num)
memo.append(num)
i,j,k = l[0],l[1],l[2]
if check[i][j][k] > 0:
turn = count-check[i][j][k]
K %= turn
ans = memo[check[i][j][k]+K-4]
print(ans)
exit()
check[i][j][k] = count
print(memo[-1])