結果
問題 | No.657 テトラナッチ数列 Easy |
ユーザー | anta |
提出日時 | 2018-03-02 22:21:46 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 1,705 bytes |
コンパイル時間 | 1,457 ms |
コンパイル使用メモリ | 165,572 KB |
実行使用メモリ | 7,164 KB |
最終ジャッジ日時 | 2023-09-03 22:19:43 |
合計ジャッジ時間 | 2,425 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 8 ms
6,920 KB |
testcase_01 | AC | 8 ms
6,980 KB |
testcase_02 | AC | 7 ms
6,924 KB |
testcase_03 | AC | 8 ms
6,856 KB |
testcase_04 | AC | 7 ms
6,924 KB |
testcase_05 | AC | 10 ms
6,988 KB |
testcase_06 | AC | 8 ms
7,164 KB |
testcase_07 | AC | 7 ms
6,928 KB |
testcase_08 | AC | 7 ms
6,920 KB |
testcase_09 | AC | 10 ms
6,984 KB |
testcase_10 | AC | 10 ms
6,924 KB |
testcase_11 | AC | 10 ms
6,968 KB |
testcase_12 | AC | 10 ms
6,924 KB |
testcase_13 | AC | 10 ms
6,936 KB |
testcase_14 | AC | 10 ms
6,932 KB |
testcase_15 | AC | 10 ms
7,044 KB |
ソースコード
#include "bits/stdc++.h" using namespace std; #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL; typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll; template<typename T, typename U> static void amin(T &x, U y) { if (y < x) x = y; } template<typename T, typename U> static void amax(T &x, U y) { if (x < y) x = y; } template<int MOD> struct ModInt { static const int Mod = MOD; unsigned x; ModInt() : x(0) { } ModInt(signed sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; } ModInt(signed long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; } int get() const { return (int)x; } ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; } ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; } ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; } ModInt operator+(ModInt that) const { return ModInt(*this) += that; } ModInt operator-(ModInt that) const { return ModInt(*this) -= that; } ModInt operator*(ModInt that) const { return ModInt(*this) *= that; } }; typedef ModInt<17> mint; int main() { int Q; while (~scanf("%d", &Q)) { const int X = (int)1e6; vector<mint> T(X + 1); T[4] = 1; rer(k, 5, X) T[k] = T[k - 1] + T[k - 2] + T[k - 3] + T[k - 4]; rep(i, Q) { int n; scanf("%d", &n); mint ans = T[n]; printf("%d\n", ans.get()); } } return 0; }