結果

問題 No.657 テトラナッチ数列 Easy
コンテスト
ユーザー @abcde
提出日時 2019-03-02 01:10:50
言語 C++11
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=gnu++11 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 15 ms / 2,000 ms
コード長 589 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 963 ms
コンパイル使用メモリ 177,152 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-03-08 06:38:06
合計ジャッジ時間 1,651 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
const int LIMIT = 1e6;

int main() {
    
    // 1. 入力情報取得.
    int Q;
    cin >> Q;
    
    // 2. Tetranacci数列 を 構成.
    int t[LIMIT];
    t[0] = 0, t[1] = 0, t[2] = 0, t[3] = 1;
    for(int i = 4; i < LIMIT; i++) t[i] = t[i - 1] + t[i - 2] + t[i - 3] + t[i - 4], t[i] %= 17;

    // 3. 各クエリごとに, Tetranacci数列 を 17 で割った余りを出力.
    for(int i = 0; i < Q; i++){
        int q;
        cin >> q;
        q--;
        cout << t[q] << endl;
    }

    // 4. 後処理.
    return 0;
    
}
0