結果

問題 No.657 テトラナッチ数列 Easy
ユーザー nnasennnasen
提出日時 2018-03-03 10:45:14
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 649 bytes
コンパイル時間 1,385 ms
コンパイル使用メモリ 164,912 KB
実行使用メモリ 7,412 KB
最終ジャッジ日時 2023-09-06 00:09:50
合計ジャッジ時間 2,492 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
7,232 KB
testcase_01 AC 9 ms
7,272 KB
testcase_02 AC 9 ms
7,252 KB
testcase_03 AC 9 ms
7,244 KB
testcase_04 AC 8 ms
7,348 KB
testcase_05 AC 22 ms
7,300 KB
testcase_06 AC 8 ms
7,244 KB
testcase_07 AC 9 ms
7,244 KB
testcase_08 AC 8 ms
7,256 KB
testcase_09 AC 24 ms
7,412 KB
testcase_10 AC 24 ms
7,240 KB
testcase_11 AC 25 ms
7,248 KB
testcase_12 AC 25 ms
7,248 KB
testcase_13 AC 26 ms
7,244 KB
testcase_14 AC 26 ms
7,268 KB
testcase_15 AC 26 ms
7,308 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n) - 1; (i) >= 0; --i)
#define SZ(n) (int)(n).size()
#define ALL(n) (n).begin(), (n).end()
#define MOD LL(1e9 + 7)
#define INF 1000000
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PI;

int tet[1000001];

int main() {
	int q;
	cin >> q;
	tet[0] = 0; tet[1] = 0; tet[2] = 0; tet[3] = 1;
	FOR(i, 4, 1000001) {
		tet[i] = tet[i - 1] + tet[i - 2] + tet[i - 3] + tet[i - 4];
		tet[i] %= 17;
	}
	while (q--) {
		int n;
		cin >> n;
		cout << tet[n - 1] << endl;
	}
	return 0;
}
0