結果

問題 No.314 ケンケンパ
ユーザー kotatsugame
提出日時 2016-12-11 08:58:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 23 ms / 1,000 ms
コード長 368 bytes
コンパイル時間 659 ms
コンパイル使用メモリ 66,328 KB
実行使用メモリ 26,880 KB
最終ジャッジ日時 2024-11-29 02:47:16
合計ジャッジ時間 1,800 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

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