結果

問題 No.657 テトラナッチ数列 Easy
ユーザー kokatsu
提出日時 2021-10-12 20:49:13
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 411 bytes
コンパイル時間 2,398 ms
コンパイル使用メモリ 203,820 KB
実行使用メモリ 8,144 KB
最終ジャッジ日時 2024-06-22 12:47:25
合計ジャッジ時間 2,591 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    int Q;
    readf("%d\n", Q);

    int M = 17;

    int nmax = 10 ^^ 6 + 1;
    auto tetranacci = new int[](nmax);
    tetranacci[4] = 1;
    int t = 1;
    foreach (i; 5 .. nmax) {
        tetranacci[i] = t;
        t = (t + tetranacci[i] - tetranacci[i-4] + M) % M;
    }

    foreach (i; 0 .. Q) {
        int n;
        readf("%d\n", n);

        tetranacci[n].writeln;
    }
}
0