結果

問題 No.657 テトラナッチ数列 Easy
ユーザー kekenxkekenx
提出日時 2020-02-02 15:43:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 361 bytes
コンパイル時間 1,508 ms
コンパイル使用メモリ 166,796 KB
実行使用メモリ 7,648 KB
最終ジャッジ日時 2023-10-19 00:55:42
合計ジャッジ時間 2,486 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
7,592 KB
testcase_01 AC 8 ms
7,592 KB
testcase_02 AC 9 ms
7,592 KB
testcase_03 AC 8 ms
7,592 KB
testcase_04 AC 8 ms
7,592 KB
testcase_05 AC 21 ms
7,648 KB
testcase_06 AC 8 ms
7,648 KB
testcase_07 AC 9 ms
7,648 KB
testcase_08 AC 8 ms
7,648 KB
testcase_09 AC 23 ms
7,648 KB
testcase_10 AC 24 ms
7,648 KB
testcase_11 AC 24 ms
7,648 KB
testcase_12 AC 24 ms
7,648 KB
testcase_13 AC 24 ms
7,648 KB
testcase_14 AC 25 ms
7,648 KB
testcase_15 AC 25 ms
7,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
int dp[1000006];

int main() {
  int q;
  cin >> q;

  dp[0] = 0;
  dp[1] = 0;
  dp[2] = 0;
  dp[3] = 1;

  for (int i = 4; i < 1000005; ++i) {
    dp[i] = dp[i - 1] + dp[i - 2] + dp[i - 3] + dp[i - 4];
    dp[i] %= 17;
  }
  while (q--) {
    int n;
    cin >> n;
    cout << dp[n - 1] << endl;
  }
  return 0;
}
0