結果

問題 No.657 テトラナッチ数列 Easy
ユーザー kanpurin002kanpurin002
提出日時 2018-11-14 01:56:56
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 9 ms / 2,000 ms
コード長 473 bytes
コンパイル時間 267 ms
コンパイル使用メモリ 29,180 KB
実行使用メモリ 5,564 KB
最終ジャッジ日時 2023-08-26 01:00:08
合計ジャッジ時間 1,203 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 6 ms
5,564 KB
testcase_01 AC 6 ms
5,552 KB
testcase_02 AC 7 ms
5,544 KB
testcase_03 AC 7 ms
5,492 KB
testcase_04 AC 7 ms
5,564 KB
testcase_05 AC 7 ms
5,472 KB
testcase_06 AC 6 ms
5,552 KB
testcase_07 AC 6 ms
5,552 KB
testcase_08 AC 6 ms
5,412 KB
testcase_09 AC 7 ms
5,496 KB
testcase_10 AC 7 ms
5,552 KB
testcase_11 AC 8 ms
5,548 KB
testcase_12 AC 8 ms
5,412 KB
testcase_13 AC 9 ms
5,440 KB
testcase_14 AC 8 ms
5,556 KB
testcase_15 AC 8 ms
5,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
	int q,*t,i;
	t=(int*)malloc(sizeof(int)*1000001);
	if (t==NULL) {
		fprintf(stderr,"malloc");
		return 1;
	}
	scanf("%d",&q);
	int n[q];
	t[0]=t[1]=t[2]=0;t[3]=1;
	for (i=4;i<1000000;i++) {
		t[i]=t[i-1]+t[i-2]+t[i-3]+t[i-4];
		t[i]%=17;
	}
	for (i=0;i<q;i++) { 
		scanf("%d",&n[i]);
	}
	//puts("----------------------");
	for (i=0;i<q;i++) {
		printf("%d\n",t[n[i]-1]);
	}
	free(t);
	return 0;
}
0