結果

問題 No.657 テトラナッチ数列 Easy
ユーザー @abcde
提出日時 2019-03-02 01:10:50
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 589 bytes
コンパイル時間 1,366 ms
コンパイル使用メモリ 158,704 KB
実行使用メモリ 7,424 KB
最終ジャッジ日時 2024-06-23 12:14:15
合計ジャッジ時間 2,330 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#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