結果

問題 No.533 Mysterious Stairs
ユーザー nikutto_nikutto_
提出日時 2017-06-23 23:21:33
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 84 ms / 5,000 ms
コード長 565 bytes
コンパイル時間 1,398 ms
コンパイル使用メモリ 148,204 KB
実行使用メモリ 57,940 KB
最終ジャッジ日時 2023-07-27 13:01:34
合計ジャッジ時間 3,079 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,384 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,384 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 12 ms
9,072 KB
testcase_21 AC 14 ms
9,900 KB
testcase_22 AC 34 ms
23,908 KB
testcase_23 AC 82 ms
56,896 KB
testcase_24 AC 84 ms
57,940 KB
testcase_25 AC 11 ms
9,052 KB
testcase_26 AC 73 ms
50,008 KB
testcase_27 AC 23 ms
16,888 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