結果

問題 No.657 テトラナッチ数列 Easy
ユーザー misora192misora192
提出日時 2020-05-21 09:25:18
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 10 ms / 2,000 ms
コード長 496 bytes
コンパイル時間 1,530 ms
コンパイル使用メモリ 164,444 KB
実行使用メモリ 7,584 KB
最終ジャッジ日時 2024-04-09 23:15:37
合計ジャッジ時間 2,390 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
7,212 KB
testcase_01 AC 8 ms
7,356 KB
testcase_02 AC 9 ms
7,344 KB
testcase_03 AC 8 ms
7,424 KB
testcase_04 AC 8 ms
7,244 KB
testcase_05 AC 9 ms
7,504 KB
testcase_06 AC 8 ms
7,420 KB
testcase_07 AC 8 ms
7,360 KB
testcase_08 AC 8 ms
7,276 KB
testcase_09 AC 9 ms
7,416 KB
testcase_10 AC 10 ms
7,420 KB
testcase_11 AC 9 ms
7,448 KB
testcase_12 AC 10 ms
7,392 KB
testcase_13 AC 10 ms
7,272 KB
testcase_14 AC 10 ms
7,584 KB
testcase_15 AC 10 ms
7,528 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int max_n = 1000000;
	int a[max_n+1];
	a[1] = 0;
	a[2] = 0;
	a[3] = 0;
	a[4] = 1;

	for(int i = 1; i + 4 <= max_n; i++){
		a[i+4] = a[i+3] + a[i+2] + a[i+1] + a[i];
		a[i+4] %= 17;
	}

	int q;
	cin >> q;

	vector<int> n(q);
	rep(i, q) cin >> n[i];

	rep(i, q){	
		cout << a[n[i]] << "\n";
	}
}
0