結果

問題 No.657 テトラナッチ数列 Easy
ユーザー tetsutetsu
提出日時 2018-03-02 22:32:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 357 bytes
コンパイル時間 476 ms
コンパイル使用メモリ 64,200 KB
実行使用メモリ 7,572 KB
最終ジャッジ日時 2023-09-03 23:15:23
合計ジャッジ時間 1,395 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <cstdio>
#include <string>
#include <iostream>
using namespace std;
#define MAX 1000001
int main() {
  int T[MAX];
  T[1] = 0; T[2] = 0; T[3]=0; T[4]=1;
  for(int i=5; i<MAX; i++) {
    T[i] = (T[i-1]+T[i-2]+T[i-3]+T[i-4])%17;
  }
  int q;
  cin >> q;
  for(int i=0; i<q; i++) {
    int n;
    cin >> n;
    printf("%d\n", T[n]);
  }
  return 0;
}
0