結果

問題 No.657 テトラナッチ数列 Easy
ユーザー zbxahzbxah
提出日時 2018-03-05 11:16:15
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 332 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,732 KB
実行使用メモリ 91,588 KB
最終ジャッジ日時 2023-09-26 14:22:03
合計ジャッジ時間 7,132 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,844 KB
testcase_01 AC 15 ms
7,884 KB
testcase_02 AC 16 ms
7,800 KB
testcase_03 AC 17 ms
7,856 KB
testcase_04 AC 239 ms
91,588 KB
testcase_05 AC 64 ms
7,884 KB
testcase_06 AC 16 ms
7,864 KB
testcase_07 AC 15 ms
7,820 KB
testcase_08 AC 267 ms
91,508 KB
testcase_09 AC 69 ms
7,856 KB
testcase_10 AC 83 ms
8,800 KB
testcase_11 AC 76 ms
8,768 KB
testcase_12 AC 279 ms
18,580 KB
testcase_13 AC 1,246 ms
91,428 KB
testcase_14 TLE -
testcase_15 AC 1,652 ms
91,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

cash = {1: 0, 2: 0, 3: 0, 4: 1}


def t(n: int) -> int:
    if n in cash:
        return cash[n]
    a, b, c, d = 1, 0, 0, 0  # n-1, ..., n-4
    for i in range(5, n + 1):
        a, b, c, d = (a + b + c + d) % 17, a, b, c
        cash[i] = a
    return a


Q = int(input())
for _ in range(Q):
    nq = int(input())
    print(t(nq))
0