結果

問題 No.657 テトラナッチ数列 Easy
ユーザー lapilapi
提出日時 2019-06-20 19:10:48
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 23 ms / 2,000 ms
コード長 784 bytes
コンパイル時間 834 ms
コンパイル使用メモリ 104,792 KB
実行使用メモリ 7,660 KB
最終ジャッジ日時 2023-08-23 07:26:07
合計ジャッジ時間 2,296 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
7,348 KB
testcase_01 AC 9 ms
7,324 KB
testcase_02 AC 9 ms
7,264 KB
testcase_03 AC 8 ms
7,324 KB
testcase_04 AC 8 ms
7,400 KB
testcase_05 AC 22 ms
7,460 KB
testcase_06 AC 9 ms
7,260 KB
testcase_07 AC 9 ms
7,324 KB
testcase_08 AC 9 ms
7,348 KB
testcase_09 AC 22 ms
7,444 KB
testcase_10 AC 22 ms
7,660 KB
testcase_11 AC 22 ms
7,532 KB
testcase_12 AC 23 ms
7,464 KB
testcase_13 AC 22 ms
7,372 KB
testcase_14 AC 23 ms
7,376 KB
testcase_15 AC 23 ms
7,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include<iomanip>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60

int T[1000009];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	T[1] = T[2] = T[3] = 0; T[4] = 1;
	for (int i = 5; i <= 1000000; i++) {
		T[i] = T[i - 1] + T[i - 2] + T[i - 3] + T[i - 4];
		T[i] %= 17;
	}

	int Q; cin >> Q;
	vector<int> ans;
	for (int i = 0; i < Q; i++) {
		int n; cin >> n;
		ans.push_back(T[n]);
	}

	for (int i = 0; i < Q; i++) cout << ans[i] << endl;


	return 0;
}
0