結果

問題 No.658 テトラナッチ数列 Hard
ユーザー mkawa2
提出日時 2020-01-07 21:46:10
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 359 bytes
コンパイル時間 242 ms
コンパイル使用メモリ 12,416 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2024-11-23 01:13:23
合計ジャッジ時間 1,562 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
def II(): return int(sys.stdin.readline())

def main():
    tt=[0,0,0,1,1]
    while 1:
        tt.append((tt[-1]*2-tt[-5])%17)
        if tt[-1]==1 and tt[-2]==0 and tt[-3]==0 and tt[-4]==0:
            break
    cycle=len(tt)-4
    q=II()
    for _ in range(q):
        n=II()-1
        print(tt[n%cycle])

main()
0