結果

問題 No.657 テトラナッチ数列 Easy
ユーザー kokatsukokatsu
提出日時 2021-10-12 20:49:13
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 16 ms / 2,000 ms
コード長 411 bytes
コンパイル時間 1,854 ms
コンパイル使用メモリ 199,696 KB
実行使用メモリ 8,500 KB
最終ジャッジ日時 2023-09-04 14:27:19
合計ジャッジ時間 3,029 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
8,500 KB
testcase_01 AC 9 ms
8,212 KB
testcase_02 AC 9 ms
7,904 KB
testcase_03 AC 9 ms
7,764 KB
testcase_04 AC 9 ms
7,472 KB
testcase_05 AC 13 ms
6,184 KB
testcase_06 AC 8 ms
6,256 KB
testcase_07 AC 9 ms
8,208 KB
testcase_08 AC 8 ms
6,116 KB
testcase_09 AC 14 ms
8,280 KB
testcase_10 AC 15 ms
8,284 KB
testcase_11 AC 14 ms
7,692 KB
testcase_12 AC 14 ms
7,640 KB
testcase_13 AC 16 ms
8,224 KB
testcase_14 AC 15 ms
7,680 KB
testcase_15 AC 16 ms
7,556 KB
権限があれば一括ダウンロードができます

ソースコード

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