結果

問題 No.657 テトラナッチ数列 Easy
ユーザー Kutimoti_TKutimoti_T
提出日時 2018-03-09 22:43:05
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 24 ms / 2,000 ms
コード長 601 bytes
コンパイル時間 807 ms
コンパイル使用メモリ 71,960 KB
実行使用メモリ 7,432 KB
最終ジャッジ日時 2024-04-18 13:38:16
合計ジャッジ時間 1,642 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
7,320 KB
testcase_01 AC 7 ms
7,252 KB
testcase_02 AC 7 ms
7,128 KB
testcase_03 AC 8 ms
7,160 KB
testcase_04 AC 8 ms
7,432 KB
testcase_05 AC 21 ms
7,344 KB
testcase_06 AC 8 ms
7,284 KB
testcase_07 AC 8 ms
7,340 KB
testcase_08 AC 8 ms
7,180 KB
testcase_09 AC 22 ms
7,264 KB
testcase_10 AC 24 ms
7,420 KB
testcase_11 AC 23 ms
7,228 KB
testcase_12 AC 22 ms
7,268 KB
testcase_13 AC 22 ms
7,392 KB
testcase_14 AC 23 ms
7,336 KB
testcase_15 AC 24 ms
7,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string.h>
#include <cmath>

using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);++(i))

int q;

int dp[1010101];

int main()
{
	dp[1] = dp[2] = dp[3] = 0;
	dp[4] = 1;
	int sum = 1;
	for(int i = 5;i <= 1010100;i++)
	{
		dp[i] = sum;
		(sum += 17 + dp[i] - dp[i - 4]) %= 17;
	}
	cin >> q;
	for(int i = 0;i < q;i++)
	{
		int a;
		cin >> a;
		cout << dp[a] << endl;
	}
	return 0;
}
0