結果

問題 No.657 テトラナッチ数列 Easy
ユーザー finefine
提出日時 2018-03-02 22:25:12
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 461 bytes
コンパイル時間 1,545 ms
コンパイル使用メモリ 163,832 KB
実行使用メモリ 7,496 KB
最終ジャッジ日時 2023-09-03 22:40:09
合計ジャッジ時間 2,536 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
7,496 KB
testcase_01 AC 8 ms
7,260 KB
testcase_02 AC 8 ms
7,224 KB
testcase_03 AC 9 ms
7,228 KB
testcase_04 AC 8 ms
7,292 KB
testcase_05 AC 22 ms
7,320 KB
testcase_06 AC 8 ms
7,232 KB
testcase_07 AC 9 ms
7,292 KB
testcase_08 AC 9 ms
7,256 KB
testcase_09 AC 23 ms
7,276 KB
testcase_10 AC 23 ms
7,360 KB
testcase_11 AC 22 ms
7,260 KB
testcase_12 AC 23 ms
7,272 KB
testcase_13 AC 23 ms
7,328 KB
testcase_14 AC 22 ms
7,256 KB
testcase_15 AC 23 ms
7,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

using ll = long long;

const int MOD = 17;

int dp[1000005];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    dp[3] = 1;
    for (int i = 4; i < 1000000; i++) {
        dp[i] = (dp[i - 1] + dp[i - 2] + dp[i - 3] + dp[i - 4]) % MOD;
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int n;
        cin >> n;
        n--;
        cout << dp[n] << endl;
    }
    return 0;
}
0