結果

問題 No.657 テトラナッチ数列 Easy
ユーザー aaaa3215aaaa3215
提出日時 2018-04-04 16:09:57
言語 C
(gcc 12.3.0)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 509 bytes
コンパイル時間 325 ms
コンパイル使用メモリ 29,348 KB
実行使用メモリ 5,848 KB
最終ジャッジ日時 2023-09-08 15:50:05
合計ジャッジ時間 1,442 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 0 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 7 ms
5,484 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 RE -
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 7 ms
5,808 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 3 ms
4,376 KB
testcase_11 AC 3 ms
4,380 KB
testcase_12 AC 3 ms
4,380 KB
testcase_13 AC 9 ms
5,848 KB
testcase_14 AC 9 ms
5,736 KB
testcase_15 AC 9 ms
5,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<stdio.h>
#include<stdlib.h>

int main(void) {
	int Q;
	int n[10000];
	unsigned int max = 1;
	int tmp = 0;

	scanf("%d", &Q);
	for (int j = 0; j < Q; j++) {
		scanf("%d", &n[j]);
		if (max < n[j]) max = n[j];
	}

	int *tt = (int *)calloc(max, sizeof(int));

	tt[0] = 0;
	tt[1] = 0;
	tt[2] = 0;
	tt[3] = 1;
	if (max > 4) {
		for (int k = 4; k <= max; k++) {
			tt[k] = (tt[k - 1] + tt[k - 2] + tt[k - 3] + tt[k - 4]) % 17;
		}
	}

	for (int i = 0; i < Q; i++) printf("%d\n", tt[n[i]-1]);

	return 0;

}
0