結果

問題 No.658 テトラナッチ数列 Hard
ユーザー wajima_wataruwajima_wataru
提出日時 2018-03-04 23:32:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 360 bytes
コンパイル時間 75 ms
コンパイル使用メモリ 10,660 KB
実行使用メモリ 8,652 KB
最終ジャッジ日時 2023-09-24 22:36:52
合計ジャッジ時間 1,583 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 22 ms
8,532 KB
testcase_01 AC 22 ms
8,484 KB
testcase_02 AC 21 ms
8,652 KB
testcase_03 AC 22 ms
8,484 KB
testcase_04 AC 73 ms
8,604 KB
testcase_05 AC 74 ms
8,508 KB
testcase_06 AC 73 ms
8,628 KB
testcase_07 AC 73 ms
8,420 KB
testcase_08 AC 75 ms
8,432 KB
testcase_09 AC 75 ms
8,380 KB
testcase_10 AC 74 ms
8,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


def tetra(i):
    if i in T:
        return T[i]
    else:
        t = (tetra(i - 1) % 17 + tetra(i - 2) % 17 + tetra(i - 3) % 17 + tetra(i - 4) % 17) % 17
        T[i] = t
        return t


for i in range(5, 4917):
    tetra(i)

Q = int(input())
for _ in range(Q):
    print(T[(int(input()) - 1) % 4912 + 1])
0