結果
問題 | No.314 ケンケンパ |
ユーザー |
![]() |
提出日時 | 2016-04-17 00:39:35 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 8 ms / 1,000 ms |
コード長 | 388 bytes |
コンパイル時間 | 450 ms |
コンパイル使用メモリ | 55,700 KB |
実行使用メモリ | 7,424 KB |
最終ジャッジ日時 | 2024-10-04 10:21:20 |
合計ジャッジ時間 | 1,228 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include<iostream>#include<string>using namespace std;#define NMAX 1000000#define MOD 1000000007int main(){int N;int dp[NMAX+1]={0};dp[0]=1;cin>>N;for(int i=0;i<=N;i++){for(int j=2;j<=3&&i+j<=N;j++){dp[i+j]+=dp[i];dp[i+j]%=MOD;}}int ans=0;if(N>=1) ans+=dp[N-1],ans%=MOD;if(N>=2) ans+=dp[N-2],ans%=MOD;ans+=dp[N],ans%=MOD;cout<<ans<<endl;}