結果

問題 No.657 テトラナッチ数列 Easy
ユーザー kashi3215
提出日時 2018-04-06 23:10:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 637 bytes
コンパイル時間 124 ms
コンパイル使用メモリ 24,832 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-06-26 10:51:44
合計ジャッジ時間 1,344 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 1 RE * 1
other AC * 5 WA * 4 RE * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:6:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
    6 |         scanf("%d", &Q);
      |         ~~~~~^~~~~~~~~~
main.cpp:11:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   11 |                 scanf("%d", &n);
      |                 ~~~~~^~~~~~~~~~
main.cpp:5:31: warning: ‘Max’ may be used uninitialized in this function [-Wmaybe-uninitialized]
    5 |         int i, j, a[5], Q, n, Max;
      |                               ^~~

ソースコード

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