結果

問題 No.658 テトラナッチ数列 Hard
ユーザー H3PO4H3PO4
提出日時 2020-11-07 08:27:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 257 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 10,600 KB
実行使用メモリ 7,888 KB
最終ジャッジ日時 2023-09-29 20:19:32
合計ジャッジ時間 1,408 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,840 KB
testcase_01 AC 19 ms
7,788 KB
testcase_02 AC 18 ms
7,844 KB
testcase_03 AC 18 ms
7,744 KB
testcase_04 AC 68 ms
7,776 KB
testcase_05 AC 69 ms
7,888 KB
testcase_06 AC 69 ms
7,800 KB
testcase_07 AC 69 ms
7,848 KB
testcase_08 AC 73 ms
7,864 KB
testcase_09 AC 70 ms
7,812 KB
testcase_10 AC 69 ms
7,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

Q = int(input())
MOD = 17

dp, first = [0, 0, 0, 1], [0, 0, 0, 1]
while True:
    dp.append((dp[-1] + dp[-2] + dp[-3] + dp[-4]) % 17)
    if dp[-4:] == first:
        break
L = len(dp) - 4

for _ in range(Q):
    N = int(input())
    print(dp[(N - 1) % L])
0