結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 8 ms
6,788 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 10 ms
7,236 KB
testcase_09 AC 3 ms
4,352 KB
testcase_10 AC 3 ms
4,352 KB
testcase_11 AC 3 ms
4,348 KB
testcase_12 AC 4 ms
4,348 KB
testcase_13 AC 11 ms
7,424 KB
testcase_14 AC 12 ms
7,356 KB
testcase_15 AC 10 ms
7,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int mx = *max_element(a.begin(), a.end());
	int t[mx + 1] = {};
	for (int i = 1; i <= mx; i++) {
		if (i == 1 || i == 2 || i == 3) t[i] = 0;
		else if (i == 4) t[i] = 1;
		else {
			t[i] = t[i - 1] + t[i - 2] + t[i - 3] + t[i - 4];
			t[i] %= 17;
		}
	}
	for (int i = 0; i < n; i++) {
		cout << t[a[i]] << '\n';
	}
	return 0;
}
0