結果

問題 No.314 ケンケンパ
ユーザー villachvillach
提出日時 2018-01-31 20:13:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 511 bytes
コンパイル時間 1,145 ms
コンパイル使用メモリ 30,924 KB
実行使用メモリ 49,920 KB
最終ジャッジ日時 2023-08-28 17:32:02
合計ジャッジ時間 1,227 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 7 ms
26,428 KB
testcase_02 AC 7 ms
26,360 KB
testcase_03 AC 8 ms
26,420 KB
testcase_04 AC 7 ms
26,424 KB
testcase_05 AC 6 ms
26,428 KB
testcase_06 AC 6 ms
26,356 KB
testcase_07 AC 7 ms
26,480 KB
testcase_08 AC 6 ms
26,424 KB
testcase_09 AC 6 ms
26,492 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 -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘long long int solve(int, int)’ 内:
main.cpp:29:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   29 | }
      | ^

ソースコード

diff #

#include <stdio.h>
#include <string.h>

using namespace std;

int N;
long long solve(int i, int j);
long long dp[1000010][3];
int main(void){
	scanf("%d", &N);

	memset(dp, -1, sizeof(dp));

	printf("%lld\n", solve(0, 0) % (1000000007));
}

long long solve(int i, int j){
	if(i == N) return 1;

	if(dp[i][j] != -1) return dp[i][j];

	if(j == 0){
		return dp[i][j] = solve(i+1, 1);
	}else if(j == 1){
		return dp[i][j] = (solve(i+1, 0) + solve(i+1, 2));
	}else if(j == 2){
		return dp[i][j] = solve(i+1, 0);
	}
}
0