結果

問題 No.657 テトラナッチ数列 Easy
ユーザー zbxahzbxah
提出日時 2018-03-05 11:26:07
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 284 ms / 2,000 ms
コード長 343 bytes
コンパイル時間 198 ms
コンパイル使用メモリ 10,672 KB
実行使用メモリ 92,016 KB
最終ジャッジ日時 2023-09-26 14:41:38
合計ジャッジ時間 2,941 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,892 KB
testcase_01 AC 16 ms
7,804 KB
testcase_02 AC 15 ms
7,824 KB
testcase_03 AC 16 ms
7,832 KB
testcase_04 AC 237 ms
91,456 KB
testcase_05 AC 38 ms
8,528 KB
testcase_06 AC 16 ms
7,844 KB
testcase_07 AC 16 ms
7,832 KB
testcase_08 AC 250 ms
91,488 KB
testcase_09 AC 41 ms
8,796 KB
testcase_10 AC 43 ms
9,412 KB
testcase_11 AC 45 ms
9,372 KB
testcase_12 AC 68 ms
19,020 KB
testcase_13 AC 284 ms
91,964 KB
testcase_14 AC 275 ms
91,876 KB
testcase_15 AC 284 ms
92,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


def t(n: int):
    a, b, c, d = tetranacci[4], tetranacci[3], tetranacci[2], tetranacci[1]
    for i in range(5, n + 1):
        a, b, c, d = (a + b + c + d) % 17, a, b, c
        tetranacci[i] = a


Q = int(input())
xs = [int(input()) for _ in range(Q)]
t(max(xs))
for x in xs:
    print(tetranacci[x])
0