結果

問題 No.657 テトラナッチ数列 Easy
ユーザー tetsuzuki1115tetsuzuki1115
提出日時 2018-04-19 03:04:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 684 bytes
コンパイル時間 731 ms
コンパイル使用メモリ 83,940 KB
実行使用メモリ 7,452 KB
最終ジャッジ日時 2023-09-09 11:31:14
合計ジャッジ時間 1,826 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
7,336 KB
testcase_01 AC 9 ms
7,336 KB
testcase_02 AC 9 ms
7,392 KB
testcase_03 AC 9 ms
7,216 KB
testcase_04 AC 8 ms
7,288 KB
testcase_05 AC 22 ms
7,312 KB
testcase_06 AC 8 ms
7,268 KB
testcase_07 AC 9 ms
7,276 KB
testcase_08 AC 8 ms
7,280 KB
testcase_09 AC 23 ms
7,260 KB
testcase_10 AC 24 ms
7,248 KB
testcase_11 AC 24 ms
7,428 KB
testcase_12 AC 24 ms
7,252 KB
testcase_13 AC 25 ms
7,372 KB
testcase_14 AC 25 ms
7,452 KB
testcase_15 AC 25 ms
7,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;


int memo[1000001] = {0};

int main() {
    int Q;
    cin >> Q;
    vector<int> A(Q);
    for ( int i = 0; i < Q; i++ ) {
        cin >> A[i];
    }

    memo[4] = 1;

    for ( int i = 5; i < 1000001; i++ ) {
        memo[i] = memo[i-1]+memo[i-2]+memo[i-3]+memo[i-4];
        memo[i] %= 17;
    }

    for ( int i = 0; i < Q; i++ ) {
        cout << memo[A[i]] << endl;
    }

    return 0;
}
0