結果

問題 No.314 ケンケンパ
ユーザー kotatsugamekotatsugame
提出日時 2016-12-11 08:58:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 1,000 ms
コード長 368 bytes
コンパイル時間 550 ms
コンパイル使用メモリ 66,672 KB
実行使用メモリ 26,900 KB
最終ジャッジ日時 2023-08-19 10:58:08
合計ジャッジ時間 1,647 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;

int main()
{
	int n;cin>>n;
	long long int dp[3][1000001]={};
	dp[0][0]=1;
	const int M=1e9+7;
	for(int i=1;i<=n;i++)
	{
		dp[0][i]=(dp[1][i-1]+dp[2][i-1])%M;
		dp[1][i]=dp[0][i-1]%M;
		dp[2][i]=dp[1][i-1]%M;
	}
	long long int ans=0;
	for(int i=0;i<3;i++)ans=(ans+dp[i][n])%M;
	cout<<ans<<endl;
	return 0;
}
0