結果

問題 No.1595 The Final Digit
ユーザー O2MTO2MT
提出日時 2021-07-09 22:34:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 560 bytes
コンパイル時間 317 ms
コンパイル使用メモリ 87,172 KB
実行使用メモリ 71,840 KB
最終ジャッジ日時 2023-09-14 09:52:14
合計ジャッジ時間 3,476 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
71,660 KB
testcase_01 AC 87 ms
71,604 KB
testcase_02 AC 84 ms
71,836 KB
testcase_03 AC 86 ms
71,560 KB
testcase_04 AC 87 ms
71,456 KB
testcase_05 AC 87 ms
71,784 KB
testcase_06 AC 86 ms
71,664 KB
testcase_07 AC 88 ms
71,744 KB
testcase_08 AC 93 ms
71,840 KB
testcase_09 AC 91 ms
71,452 KB
testcase_10 AC 93 ms
71,716 KB
testcase_11 AC 90 ms
71,628 KB
testcase_12 AC 90 ms
71,508 KB
testcase_13 AC 90 ms
71,604 KB
testcase_14 AC 91 ms
71,752 KB
testcase_15 AC 90 ms
71,460 KB
testcase_16 AC 92 ms
71,708 KB
testcase_17 AC 95 ms
71,600 KB
testcase_18 AC 94 ms
71,608 KB
testcase_19 AC 89 ms
71,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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])
0