結果

問題 No.533 Mysterious Stairs
ユーザー ukuku09ukuku09
提出日時 2017-06-23 22:49:47
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 75 ms / 5,000 ms
コード長 1,069 bytes
コンパイル時間 1,256 ms
コンパイル使用メモリ 158,944 KB
実行使用メモリ 65,816 KB
最終ジャッジ日時 2024-04-15 00:57:31
合計ジャッジ時間 2,520 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
34,632 KB
testcase_01 AC 9 ms
34,576 KB
testcase_02 AC 11 ms
34,608 KB
testcase_03 AC 10 ms
34,428 KB
testcase_04 AC 9 ms
34,512 KB
testcase_05 AC 11 ms
34,440 KB
testcase_06 AC 10 ms
34,528 KB
testcase_07 AC 10 ms
34,572 KB
testcase_08 AC 9 ms
34,556 KB
testcase_09 AC 11 ms
34,544 KB
testcase_10 AC 10 ms
34,584 KB
testcase_11 AC 11 ms
34,600 KB
testcase_12 AC 10 ms
34,620 KB
testcase_13 AC 10 ms
34,624 KB
testcase_14 AC 11 ms
34,580 KB
testcase_15 AC 9 ms
34,656 KB
testcase_16 AC 11 ms
34,708 KB
testcase_17 AC 11 ms
34,796 KB
testcase_18 AC 11 ms
34,908 KB
testcase_19 AC 11 ms
34,740 KB
testcase_20 AC 16 ms
38,052 KB
testcase_21 AC 19 ms
38,300 KB
testcase_22 AC 36 ms
46,504 KB
testcase_23 AC 75 ms
65,464 KB
testcase_24 AC 75 ms
65,816 KB
testcase_25 AC 18 ms
38,104 KB
testcase_26 AC 66 ms
61,456 KB
testcase_27 AC 27 ms
42,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

typedef pair<int, int> Pi;
typedef tuple<int, int, int> Ti;
typedef vector<int> vint;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

int N;
int dp[4][1000010];

int solve(int prev, int step) {
  if(step == N) return 1;
  else if(step > N) return 0;
  int &res = dp[prev][step];
  if(~res) return res;
  res = 0;
  if(prev != 1) (res += solve(1, step+1)) %= mod;
  if(prev != 2) (res += solve(2, step+2)) %= mod;
  if(prev != 3) (res += solve(3, step+3)) %= mod;
  return res;
}

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N;
  memset(dp, -1, sizeof(dp));
  cout << solve(0, 0) << endl;

  return 0;
}
0