結果

問題 No.657 テトラナッチ数列 Easy
ユーザー tkmst201tkmst201
提出日時 2021-01-19 09:54:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 957 bytes
コンパイル時間 3,664 ms
コンパイル使用メモリ 238,528 KB
実行使用メモリ 7,628 KB
最終ジャッジ日時 2023-08-22 06:49:20
合計ジャッジ時間 4,939 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
7,396 KB
testcase_01 AC 8 ms
7,476 KB
testcase_02 AC 8 ms
7,552 KB
testcase_03 AC 8 ms
7,476 KB
testcase_04 AC 8 ms
7,340 KB
testcase_05 AC 10 ms
7,392 KB
testcase_06 AC 8 ms
7,336 KB
testcase_07 AC 8 ms
7,480 KB
testcase_08 AC 8 ms
7,340 KB
testcase_09 AC 10 ms
7,392 KB
testcase_10 AC 10 ms
7,372 KB
testcase_11 AC 10 ms
7,388 KB
testcase_12 AC 10 ms
7,628 KB
testcase_13 AC 11 ms
7,436 KB
testcase_14 AC 11 ms
7,304 KB
testcase_15 AC 10 ms
7,428 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = false;
//---------------------------------//

template<int N> struct DP {
	int dp[N];
	
	constexpr DP() : dp() {
		dp[3] = 1;
		for (int i = 4; i < N; ++i) dp[i] = (dp[i - 1] + dp[i - 2] + dp[i - 3] + dp[i - 4]) % 17;
	}
	
	int operator [](int i) { return dp[i]; }
};

int main() {
	DP<1000000> dp;
	
	int Q;
	cin >> Q;
	while (Q--) {
		int n;
		scanf("%d", &n);
		printf("%d\n", dp[n - 1]);
	}
}
0