結果

問題 No.657 テトラナッチ数列 Easy
ユーザー merom686merom686
提出日時 2018-03-02 22:24:54
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 575 ms
コンパイル使用メモリ 74,236 KB
実行使用メモリ 6,996 KB
最終ジャッジ日時 2023-09-03 22:37:11
合計ジャッジ時間 1,526 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
6,984 KB
testcase_01 AC 8 ms
6,908 KB
testcase_02 AC 8 ms
6,904 KB
testcase_03 AC 8 ms
6,728 KB
testcase_04 AC 8 ms
6,752 KB
testcase_05 AC 9 ms
6,868 KB
testcase_06 AC 8 ms
6,924 KB
testcase_07 AC 8 ms
6,752 KB
testcase_08 AC 7 ms
6,996 KB
testcase_09 AC 10 ms
6,964 KB
testcase_10 AC 9 ms
6,908 KB
testcase_11 AC 9 ms
6,908 KB
testcase_12 AC 10 ms
6,796 KB
testcase_13 AC 9 ms
6,908 KB
testcase_14 AC 9 ms
6,908 KB
testcase_15 AC 9 ms
6,964 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

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

    int m = 1000000;
    vector<int> p(m);
    p[3] = 1;
    for (int i = 4; i < m; i++) {
        p[i] = (p[i - 1] + p[i - 2] + p[i - 3] + p[i - 4]) % 17;
    }

    int q;
    cin >> q;

    for (int i = 0; i < q; i++) {
        int n;
        cin >> n;
        n--;

        cout << p[n] << '\n';
    }

    return 0;
}
0