結果

問題 No.658 テトラナッチ数列 Hard
ユーザー GrayCoderGrayCoder
提出日時 2018-03-03 21:12:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 427 bytes
コンパイル時間 113 ms
コンパイル使用メモリ 10,640 KB
実行使用メモリ 8,884 KB
最終ジャッジ日時 2023-09-17 21:12:02
合計ジャッジ時間 1,361 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 18 ms
7,808 KB
testcase_01 AC 18 ms
7,812 KB
testcase_02 AC 18 ms
7,812 KB
testcase_03 AC 18 ms
7,696 KB
testcase_04 AC 42 ms
8,772 KB
testcase_05 AC 41 ms
8,768 KB
testcase_06 AC 42 ms
8,828 KB
testcase_07 AC 42 ms
8,652 KB
testcase_08 AC 43 ms
8,876 KB
testcase_09 AC 43 ms
8,736 KB
testcase_10 AC 42 ms
8,884 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    Q = int(input())
    N = tuple(int(input()) for _ in [0] * Q)

    tetra = [0, 0, 0, 1, 1]
    apnd = tetra.append
    i = 1
    while 1:
        if all((not tetra[i], not tetra[i+1], not tetra[i+2], tetra[i+3] == 1)):
            break
        else:
            apnd((tetra[i] + tetra[i+1] + tetra[i+2] + tetra[i+3]) % 17)
        i += 1

    for n in N:
        print(tetra[(n-1) % (len(tetra) - 4)])

main()
0