結果

問題 No.657 テトラナッチ数列 Easy
ユーザー iqueue02iqueue02
提出日時 2019-10-26 15:10:44
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 27 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 1,391 ms
コンパイル使用メモリ 163,808 KB
実行使用メモリ 11,328 KB
最終ジャッジ日時 2023-10-12 09:46:29
合計ジャッジ時間 2,529 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
11,252 KB
testcase_01 AC 9 ms
11,152 KB
testcase_02 AC 9 ms
11,164 KB
testcase_03 AC 10 ms
11,292 KB
testcase_04 AC 10 ms
11,156 KB
testcase_05 AC 24 ms
11,272 KB
testcase_06 AC 9 ms
11,232 KB
testcase_07 AC 10 ms
11,168 KB
testcase_08 AC 9 ms
11,252 KB
testcase_09 AC 25 ms
11,228 KB
testcase_10 AC 25 ms
11,156 KB
testcase_11 AC 26 ms
11,232 KB
testcase_12 AC 26 ms
11,164 KB
testcase_13 AC 27 ms
11,276 KB
testcase_14 AC 27 ms
11,220 KB
testcase_15 AC 27 ms
11,328 KB
権限があれば一括ダウンロードができます

ソースコード

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