結果

問題 No.658 テトラナッチ数列 Hard
ユーザー oshiborioshibori
提出日時 2018-03-02 23:28:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 21 ms / 2,000 ms
コード長 1,359 bytes
コンパイル時間 2,017 ms
コンパイル使用メモリ 176,636 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-04 13:10:20
合計ジャッジ時間 3,102 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
4,376 KB
testcase_01 AC 5 ms
4,376 KB
testcase_02 AC 5 ms
4,380 KB
testcase_03 AC 5 ms
4,380 KB
testcase_04 AC 20 ms
4,380 KB
testcase_05 AC 19 ms
4,384 KB
testcase_06 AC 19 ms
4,376 KB
testcase_07 AC 20 ms
4,380 KB
testcase_08 AC 21 ms
4,376 KB
testcase_09 AC 20 ms
4,380 KB
testcase_10 AC 21 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
// typedef __int128_t Int;
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
    sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template <class T> bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T> bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(12);

  int Q;
  cin >> Q;
  int N = 5000;
  vector<int> T(N);
  T[0] = T[1] = T[2] = 0;
  T[3] = 1;
  map<vector<int>, int> s;
  //  s[vector<int>{0, 0, 0, 1}] = 3;

  rep(i, 4, N) {
    dump(i);
    T[i] = (T[i - 1] + T[i - 2] + T[i - 3] + T[i - 4]) % 17;
    vector<int> v{T[i], T[i - 1], T[i - 2], T[i - 3]};
    if (s[v] != 0) {
      dump(s[v]);
    }
    s[v] = i;
  }
  dump(T);
  loop(Q) {
    int x;
    cin >> x;
    x--;
    cout << T[x % 4912] << endl;
  }

  return 0;
}
0