結果

問題 No.1595 The Final Digit
ユーザー ああいいああいい
提出日時 2021-12-08 17:53:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 467 bytes
コンパイル時間 81 ms
コンパイル使用メモリ 10,816 KB
実行使用メモリ 7,996 KB
最終ジャッジ日時 2023-09-23 08:18:12
合計ジャッジ時間 2,224 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,808 KB
testcase_01 AC 16 ms
7,744 KB
testcase_02 AC 15 ms
7,816 KB
testcase_03 AC 15 ms
7,896 KB
testcase_04 WA -
testcase_05 AC 16 ms
7,828 KB
testcase_06 AC 16 ms
7,832 KB
testcase_07 AC 15 ms
7,840 KB
testcase_08 AC 16 ms
7,800 KB
testcase_09 AC 16 ms
7,996 KB
testcase_10 AC 16 ms
7,800 KB
testcase_11 AC 16 ms
7,796 KB
testcase_12 AC 16 ms
7,828 KB
testcase_13 AC 16 ms
7,876 KB
testcase_14 AC 16 ms
7,944 KB
testcase_15 AC 16 ms
7,972 KB
testcase_16 AC 16 ms
7,812 KB
testcase_17 AC 15 ms
7,836 KB
testcase_18 AC 16 ms
7,796 KB
testcase_19 AC 16 ms
7,824 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

A = [0] * 1001
A[1] = p
A[2] = q
A[3] = r
memo = [0] * 1000
memo[p * 100 + q * 10 + r] = 3

i = 4
while True:
    A[i] = A[i-1] + A[i-2] + A[i-3]
    A[i] %= 10
    u = A[i] * 100 + A[i-1] * 10 + A[i-2]
    if memo[u]:
        loop = i - memo[u]
        start = memo[u]
        break
    else:
        memo[u] = i
    i += 1
if K <= start:print(A[K])
else:
    r = (K - start) % loop
    print(A[start+r])
0