結果

問題 No.657 テトラナッチ数列 Easy
コンテスト
ユーザー aaaa3215
提出日時 2018-04-04 16:09:57
言語 C(gnu17)
(gcc 15.2.0)
コンパイル:
gcc-15 -O2 -std=gnu17 -Wno-error=implicit-function-declaration -Wno-error=implicit-int -Wno-error=incompatible-pointer-types -Wno-error=int-conversion -DONLINE_JUDGE -o a.out _filename_ -lm
実行:
./a.out
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 509 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 190 ms
コンパイル使用メモリ 39,140 KB
最終ジャッジ日時 2026-02-22 00:57:35
ジャッジサーバーID
(参考情報)
judge1 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 RE * 1
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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