結果

問題 No.533 Mysterious Stairs
ユーザー nikutto_nikutto_
提出日時 2017-06-23 23:21:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 86 ms / 5,000 ms
コード長 565 bytes
コンパイル時間 1,470 ms
コンパイル使用メモリ 163,100 KB
実行使用メモリ 57,816 KB
最終ジャッジ日時 2024-04-15 01:06:15
合計ジャッジ時間 2,589 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 1 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 1 ms
6,940 KB
testcase_07 AC 1 ms
6,940 KB
testcase_08 AC 1 ms
6,940 KB
testcase_09 AC 2 ms
6,944 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 1 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 3 ms
6,940 KB
testcase_20 AC 13 ms
9,344 KB
testcase_21 AC 13 ms
9,984 KB
testcase_22 AC 34 ms
24,104 KB
testcase_23 AC 85 ms
57,252 KB
testcase_24 AC 86 ms
57,816 KB
testcase_25 AC 13 ms
9,344 KB
testcase_26 AC 76 ms
50,268 KB
testcase_27 AC 23 ms
16,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
  int n;
  cin>>n;
  vector<vector<long long int>> dp(n+3,vector<long long int>(3,0));
  const long long int MOD=1e9+7;
  dp[0][0]=1;
  dp[0][1]=0;
  dp[0][2]=0;
  dp[1][0]=0;
  dp[1][1]=1;
  dp[1][2]=0;
  dp[2][0]=1;
  dp[2][1]=1;
  dp[2][2]=1;
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      dp[i+3][j]=dp[i+2-j][0]+dp[i+2-j][1]+dp[i+2-j][2]-dp[i+2-j][j];
      dp[i+3][j]%=MOD;
      dp[i+3][j]=(dp[i+3][j]+MOD)%MOD;
    }
  }
  cout<<(dp[n-1][0]+dp[n-1][1]+dp[n-1][2])%MOD<<endl;
  return 0;

}
0