結果

問題 No.657 テトラナッチ数列 Easy
ユーザー mamekinmamekin
提出日時 2018-03-25 11:47:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 793 bytes
コンパイル時間 1,757 ms
コンパイル使用メモリ 101,228 KB
実行使用メモリ 6,952 KB
最終ジャッジ日時 2023-09-07 11:32:53
合計ジャッジ時間 2,204 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
6,760 KB
testcase_01 AC 8 ms
6,876 KB
testcase_02 AC 9 ms
6,852 KB
testcase_03 AC 8 ms
6,932 KB
testcase_04 AC 8 ms
6,896 KB
testcase_05 AC 23 ms
6,924 KB
testcase_06 AC 8 ms
6,912 KB
testcase_07 AC 8 ms
6,780 KB
testcase_08 AC 9 ms
6,716 KB
testcase_09 AC 23 ms
6,892 KB
testcase_10 AC 24 ms
6,716 KB
testcase_11 AC 24 ms
6,724 KB
testcase_12 AC 25 ms
6,780 KB
testcase_13 AC 25 ms
6,952 KB
testcase_14 AC 25 ms
6,892 KB
testcase_15 AC 25 ms
6,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const int MAX = 1000000;
const int MOD = 17;

int main()
{
    vector<int> v(MAX+1, 0);
    v[4] = 1;
    for(int i=5; i<=MAX; ++i){
        v[i] = v[i-1] + v[i-2] + v[i-3] + v[i-4];
        v[i] %= MOD;
    }

    int q;
    cin >> q;
    while(--q >= 0){
        int n;
        cin >> n;
        cout << v[n] << endl;
    }

    return 0;
}
0