結果

問題 No.657 テトラナッチ数列 Easy
ユーザー hitoyozakehitoyozake
提出日時 2018-04-14 15:56:28
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 588 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 10,852 KB
実行使用メモリ 9,116 KB
最終ジャッジ日時 2023-09-09 05:10:25
合計ジャッジ時間 2,668 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,612 KB
testcase_01 AC 18 ms
8,564 KB
testcase_02 AC 19 ms
8,612 KB
testcase_03 AC 18 ms
8,452 KB
testcase_04 RE -
testcase_05 AC 44 ms
8,880 KB
testcase_06 AC 19 ms
8,424 KB
testcase_07 AC 19 ms
8,492 KB
testcase_08 RE -
testcase_09 AC 953 ms
9,116 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

# -* encoding: utf-8 *-
import collections


def tetra(map, n):

    if n <= 3:
        return 0
    elif n == 4:
        return 1

    if n not in map:
        map[n] = tetra(map=map, n=n-1) + tetra(map=map, n=n-2) + tetra(map=map, n=n-3) + tetra(map=map, n=n-4)

    return map[n]

def main():
    n = int(input().split()[0])
    ar = []

    mp = {}

    for i in range(n):
        x = int(input().split()[0])

        for i in range(x):
            tetra(map=mp, n=x)

        ar.append(tetra(map=mp, n=x))

    for i in ar:
        print(i%17)


if __name__ == '__main__':
    main()
0