結果

問題 No.657 テトラナッチ数列 Easy
ユーザー MisterMister
提出日時 2020-04-16 09:49:36
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 546 bytes
コンパイル時間 517 ms
コンパイル使用メモリ 74,872 KB
実行使用メモリ 7,240 KB
最終ジャッジ日時 2024-04-09 19:07:38
合計ジャッジ時間 1,462 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
7,204 KB
testcase_01 AC 8 ms
7,128 KB
testcase_02 AC 8 ms
7,240 KB
testcase_03 AC 8 ms
7,140 KB
testcase_04 AC 8 ms
7,152 KB
testcase_05 AC 19 ms
7,132 KB
testcase_06 AC 8 ms
7,076 KB
testcase_07 AC 8 ms
7,060 KB
testcase_08 AC 8 ms
7,104 KB
testcase_09 AC 20 ms
7,000 KB
testcase_10 AC 21 ms
7,172 KB
testcase_11 AC 21 ms
7,208 KB
testcase_12 AC 20 ms
7,000 KB
testcase_13 AC 20 ms
7,092 KB
testcase_14 AC 20 ms
7,200 KB
testcase_15 AC 19 ms
7,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

constexpr int N = 1000000;
constexpr int MOD = 17;

void solve() {
    std::vector<int> xs(N + 1, 0);
    xs[4] = 1;
    for (int i = 5; i <= N; ++i) {
        for (int j = 1; j <= 4; ++j) {
            xs[i] += xs[i - j];
        }
        xs[i] %= MOD;
    }

    int q;
    std::cin >> q;
    while (q--) {
        int n;
        std::cin >> n;
        std::cout << xs[n] << std::endl;
    }
}

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);

    solve();

    return 0;
}
0