結果

問題 No.657 テトラナッチ数列 Easy
コンテスト
ユーザー kobaryo222
提出日時 2018-03-02 22:30:22
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 31 ms / 2,000 ms
コード長 1,145 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 648 ms
コンパイル使用メモリ 98,896 KB
実行使用メモリ 7,716 KB
最終ジャッジ日時 2026-03-05 23:52:45
合計ジャッジ時間 1,607 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <unordered_set>
#include <unordered_map>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const int INF = 1000010000;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};

int a[1000010];

int main(){
    int q;
    cin >> q;
    REP(i, 1000010){
        if(i < 3) a[i] = 0;
        else if(i == 3) a[i] = 1;
        else a[i] = (a[i - 1] + a[i - 2] + a[i - 3] + a[i - 4]) % 17;
    }
    REP(i, q){
        int tmp;
        cin >> tmp;
        cout << a[tmp - 1] << endl;
    }
    return 0;
}
0