結果

問題 No.314 ケンケンパ
ユーザー silopysilopy
提出日時 2019-07-05 20:00:35
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 1,000 ms
コード長 415 bytes
コンパイル時間 560 ms
コンパイル使用メモリ 66,696 KB
実行使用メモリ 15,412 KB
最終ジャッジ日時 2023-10-22 03:26:50
合計ジャッジ時間 1,598 ms
ジャッジサーバーID
(参考情報)
judge12 / judge9
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
using lint=int64_t;

const int mod=1e9+7;

int main()
{
	int N;

	cin >> N;

	int dp[1000010][3]={};
	dp[0][0]=1;
	for(int i=0;i<N;i++)
	{
		dp[i+1][0]+=(dp[i][1]+dp[i][2]);
		dp[i+1][1]+=dp[i][0];
		dp[i+1][2]+=dp[i][1];
		dp[i+1][0]%=mod;
		dp[i+1][1]%=mod;
		dp[i+1][2]%=mod;
	}

	cout << (((dp[N][0]+dp[N][1])%mod)+dp[N][2])%mod << endl;
	return 0;
}
0