結果

問題 No.657 テトラナッチ数列 Easy
ユーザー merom686merom686
提出日時 2018-03-02 22:24:54
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 538 bytes
コンパイル時間 594 ms
コンパイル使用メモリ 74,856 KB
実行使用メモリ 7,184 KB
最終ジャッジ日時 2024-06-13 03:14:47
合計ジャッジ時間 1,390 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

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