結果

問題 No.314 ケンケンパ
ユーザー C_kumoC_kumo
提出日時 2019-01-21 23:10:24
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 463 bytes
コンパイル時間 1,286 ms
コンパイル使用メモリ 28,216 KB
実行使用メモリ 4,480 KB
最終ジャッジ日時 2023-10-13 17:29:08
合計ジャッジ時間 1,359 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 0 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,352 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 0 ms
4,348 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

#define ANS (1000000000+7)

int searchDP(int n);

int main(void)
{
	int n,ret;
	scanf("%d",&n);

	ret = searchDP(n);

	printf("%d\n",ret);
	
	return 0;
}

int searchDP(int n)
{
	int i,j;
	long long dp[4];
	if      (n==1) return 1;
	else if (n==2) return 2;
	else if (n==3) return 2;

	dp[0] = 1;
	dp[1] = 2;
	dp[2] = 2;
	for (i=3;i<n;i++) {
		dp[3] = dp[0] + dp[1];
		for (j=1;j<4;j++) {
			dp[j-1] = dp[j];
		}
	}
	return (int)(dp[3]%ANS);
}
0