結果

問題 No.657 テトラナッチ数列 Easy
ユーザー kashi3215kashi3215
提出日時 2018-04-06 23:10:02
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 637 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 27,240 KB
実行使用メモリ 6,908 KB
最終ジャッジ日時 2023-09-08 18:05:42
合計ジャッジ時間 2,511 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 3 ms
4,384 KB
testcase_06 RE -
testcase_07 AC 2 ms
4,384 KB
testcase_08 WA -
testcase_09 RE -
testcase_10 RE -
testcase_11 WA -
testcase_12 RE -
testcase_13 WA -
testcase_14 WA -
testcase_15 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:31:16: warning: ‘Max’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  for (i = 0; i < Max - 3; i++) {
              ~~^~~~~~~~~

ソースコード

diff #

#include<cstdio>
#include<cstdlib>
int main(void)
{
	int i, j, a[5], Q, n, Max;
	scanf("%d", &Q);
	int *b = (int *)calloc(Q, sizeof(int));
	for (j = 0; j < Q; j++) {


		scanf("%d", &n);
		b[j] = n;
		Max = 0;
		if (b[j] > Max) {
			Max = b[j];
		}
	}


	int *c = (int *)calloc(Max, sizeof(int));

	a[0] = 0;
	a[1] = 0;
	a[2] = 0;
	a[3] = 1;
	c[0] = 0;
	c[1] = 0;
	c[2] = 0;
	c[3] = 0;

	for (i = 0; i < Max - 3; i++) {
		a[4] = (a[3] + a[2] + a[1] + a[0]) % 17;
		a[0] = a[1];
		a[1] = a[2];
		a[2] = a[3];
		a[3] = a[4];


		c[i + 4] = a[4] % 17;
	}
	for (j = 0; j < Q; j++) {

		printf("%d", c[b[j]]);
		printf("\n");
	}

	return 0;
}
0