結果
問題 |
No.314 ケンケンパ
|
ユーザー |
![]() |
提出日時 | 2018-08-03 14:29:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 18 ms / 1,000 ms |
コード長 | 508 bytes |
コンパイル時間 | 1,828 ms |
コンパイル使用メモリ | 166,276 KB |
実行使用メモリ | 34,816 KB |
最終ジャッジ日時 | 2024-09-19 17:22:09 |
合計ジャッジ時間 | 2,446 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 17 |
ソースコード
#include<bits/stdc++.h> using namespace std; using Int = long long; //INSERT ABOVE HERE const Int MAX = 1e6+100; const Int MOD = 1e9+7; Int dp[4][MAX]; signed main(){ Int n; cin>>n; memset(dp,0,sizeof(dp)); dp[0][0]=1; for(Int i=0;i<n;i++){ for(Int j=0;j<4;j++){ dp[j][i]%=MOD; if(j+1<3) dp[j+1][i+1]+=dp[j][i]; if(j) dp[0][i+1]+=dp[j][i]; } } Int ans=0; for(Int j=0;j<4;j++){ dp[j][n]%=MOD; ans+=dp[j][n]; ans%=MOD; } cout<<ans<<endl; return 0; }