結果

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

ソースコード

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