結果

問題 No.1595 The Final Digit
ユーザー shinichishinichi
提出日時 2021-07-09 22:17:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 440 bytes
コンパイル時間 284 ms
コンパイル使用メモリ 87,180 KB
実行使用メモリ 71,568 KB
最終ジャッジ日時 2023-09-14 09:31:15
合計ジャッジ時間 3,070 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,568 KB
testcase_01 AC 69 ms
71,376 KB
testcase_02 AC 70 ms
71,344 KB
testcase_03 AC 74 ms
71,420 KB
testcase_04 AC 70 ms
71,280 KB
testcase_05 AC 70 ms
71,312 KB
testcase_06 AC 71 ms
71,440 KB
testcase_07 AC 72 ms
71,372 KB
testcase_08 AC 71 ms
71,240 KB
testcase_09 AC 72 ms
71,244 KB
testcase_10 AC 73 ms
71,352 KB
testcase_11 AC 72 ms
71,484 KB
testcase_12 AC 71 ms
71,536 KB
testcase_13 AC 72 ms
71,260 KB
testcase_14 AC 72 ms
71,404 KB
testcase_15 AC 71 ms
71,356 KB
testcase_16 AC 71 ms
71,372 KB
testcase_17 AC 75 ms
71,440 KB
testcase_18 AC 74 ms
71,452 KB
testcase_19 AC 72 ms
71,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

p, q, r, K = map(int, input().split())

p %= 10
q %= 10
r %= 10
data = set((p, q, r))
array = [p, q, r]
while True:
    array.append((sum(array[-3:])%10))
    if tuple(array[-3:]) in data:
        break
    data.add(tuple(array[-3:]))
for i in range(len(array)-3):
    if array[i:i+3] == array[-3:]:
        start = i
        break
cycle = len(array) - 3 - start


target_index = (K-start) % cycle
result = array[target_index]
print(result)
0