結果

問題 No.533 Mysterious Stairs
ユーザー iqueue02
提出日時 2019-11-08 17:01:02
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 41 ms / 5,000 ms
コード長 477 bytes
コンパイル時間 1,717 ms
コンパイル使用メモリ 166,072 KB
実行使用メモリ 19,072 KB
最終ジャッジ日時 2024-09-15 00:52:01
合計ジャッジ時間 2,723 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

const int mod = 1e9+7;

int dp[1000010][4]; 

int main(){
  int n;
  cin >> n;
  dp[0][0] = 1;
  rep(i,n) rep(j,4) {
    for (int k = 1; k < 4; k++) if (k != j) {
      (dp[i+k][k] += dp[i][j]) %= mod;
    }
  }
  int res = 0;
  rep(i,4) {
    (res += dp[n][i]) %= mod;
  }
  cout << res << endl;
  return 0;
}
0