結果

問題 No.314 ケンケンパ
ユーザー beetbeet
提出日時 2018-08-03 14:29:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 1,000 ms
コード長 508 bytes
コンパイル時間 1,516 ms
コンパイル使用メモリ 167,000 KB
実行使用メモリ 34,912 KB
最終ジャッジ日時 2023-10-19 21:19:05
合計ジャッジ時間 2,720 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
}
0