結果

問題 No.657 テトラナッチ数列 Easy
ユーザー @abcde@abcde
提出日時 2019-03-02 01:10:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 589 bytes
コンパイル時間 1,137 ms
コンパイル使用メモリ 143,976 KB
実行使用メモリ 7,440 KB
最終ジャッジ日時 2023-09-05 16:45:03
合計ジャッジ時間 2,269 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
7,376 KB
testcase_01 AC 9 ms
7,256 KB
testcase_02 AC 9 ms
7,308 KB
testcase_03 AC 9 ms
7,236 KB
testcase_04 AC 9 ms
7,312 KB
testcase_05 AC 23 ms
7,308 KB
testcase_06 AC 9 ms
7,312 KB
testcase_07 AC 9 ms
7,308 KB
testcase_08 AC 9 ms
7,308 KB
testcase_09 AC 24 ms
7,248 KB
testcase_10 AC 25 ms
7,372 KB
testcase_11 AC 25 ms
7,252 KB
testcase_12 AC 26 ms
7,420 KB
testcase_13 AC 26 ms
7,252 KB
testcase_14 AC 25 ms
7,440 KB
testcase_15 AC 25 ms
7,308 KB
権限があれば一括ダウンロードができます

ソースコード

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