結果
問題 | No.1595 The Final Digit |
ユーザー |
|
提出日時 | 2021-07-09 22:34:32 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 44 ms / 2,000 ms |
コード長 | 560 bytes |
コンパイル時間 | 490 ms |
コンパイル使用メモリ | 82,060 KB |
実行使用メモリ | 55,796 KB |
最終ジャッジ日時 | 2024-07-01 17:14:57 |
合計ジャッジ時間 | 3,221 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
from collections import dequep,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] = 3memo = [p,q,r]count = 3l = deque([p,q,r])while count < K:count += 1num = 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 %= turnans = memo[check[i][j][k]+K-4]print(ans)exit()check[i][j][k] = countprint(memo[-1])