結果

問題 No.533 Mysterious Stairs
ユーザー iqueue02iqueue02
提出日時 2019-11-08 17:01:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 5,000 ms
コード長 477 bytes
コンパイル時間 1,696 ms
コンパイル使用メモリ 163,900 KB
実行使用メモリ 18,976 KB
最終ジャッジ日時 2023-10-13 03:13:17
合計ジャッジ時間 3,231 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 1 ms
4,372 KB
testcase_02 AC 1 ms
4,372 KB
testcase_03 AC 2 ms
4,368 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 1 ms
4,368 KB
testcase_06 AC 2 ms
4,368 KB
testcase_07 AC 2 ms
4,368 KB
testcase_08 AC 2 ms
4,372 KB
testcase_09 AC 1 ms
4,368 KB
testcase_10 AC 2 ms
4,372 KB
testcase_11 AC 2 ms
4,368 KB
testcase_12 AC 1 ms
4,372 KB
testcase_13 AC 2 ms
4,372 KB
testcase_14 AC 2 ms
4,368 KB
testcase_15 AC 2 ms
4,368 KB
testcase_16 AC 2 ms
4,376 KB
testcase_17 AC 2 ms
4,372 KB
testcase_18 AC 2 ms
4,372 KB
testcase_19 AC 2 ms
4,372 KB
testcase_20 AC 7 ms
5,284 KB
testcase_21 AC 7 ms
5,260 KB
testcase_22 AC 18 ms
9,388 KB
testcase_23 AC 40 ms
18,768 KB
testcase_24 AC 41 ms
18,976 KB
testcase_25 AC 6 ms
5,160 KB
testcase_26 AC 35 ms
16,804 KB
testcase_27 AC 12 ms
7,420 KB
権限があれば一括ダウンロードができます

ソースコード

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