結果

問題 No.314 ケンケンパ
ユーザー umezoumezo
提出日時 2022-08-08 00:35:47
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 34 ms / 1,000 ms
コード長 520 bytes
コンパイル時間 1,958 ms
コンパイル使用メモリ 201,184 KB
実行使用メモリ 27,036 KB
最終ジャッジ日時 2023-10-17 18:58:36
合計ジャッジ時間 3,174 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
26,640 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 3 ms
4,348 KB
testcase_17 AC 5 ms
5,944 KB
testcase_18 AC 18 ms
14,812 KB
testcase_19 AC 34 ms
27,036 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(v) v.begin(),v.end()
typedef long long ll;

#include<bits/stdc++.h>
using namespace std;

ll dp[1000100][3];
const int MOD=1e9+7;

int main(){
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);

  int n;
  cin>>n;
  dp[0][0]=1;
  rep(i,n){
    rep(j,3){
      if(j<2) dp[i+1][j+1]=(dp[i+1][j+1]+dp[i][j])%MOD;
      if(j>0) dp[i+1][0]=(dp[i+1][0]+dp[i][j])%MOD;
    }
  }
  ll ans=0;
  rep(j,3) ans=(ans+dp[n][j])%MOD;
  cout<<ans<<endl;
      
  return 0;
}
0