結果

問題 No.657 テトラナッチ数列 Easy
ユーザー iqueue02
提出日時 2019-10-26 15:10:44
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 1,483 ms
コンパイル使用メモリ 167,152 KB
実行使用メモリ 11,392 KB
最終ジャッジ日時 2024-09-14 08:40:41
合計ジャッジ時間 2,700 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

const int mod = 17;
const int NMAX = 1000000;
ll t[NMAX];

void init(){
  t[3] = 1;
  for (int i = 4; i < NMAX; i++) {
    (t[i] = t[i-1] + t[i-2] + t[i-3] + t[i-4]) %= mod;
  }
}

int main(){

  int q;
  cin >> q;
  init();
  rep(i,q) {
    int n;
    cin >> n;
    cout << t[--n] << endl;
  }
  return 0;
}
0