結果

問題 No.533 Mysterious Stairs
ユーザー seriru13seriru13
提出日時 2019-05-23 22:19:07
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 90 ms / 5,000 ms
コード長 1,357 bytes
コンパイル時間 1,099 ms
コンパイル使用メモリ 115,972 KB
実行使用メモリ 58,096 KB
最終ジャッジ日時 2023-10-17 11:36:31
合計ジャッジ時間 3,091 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 3 ms
4,348 KB
testcase_19 AC 3 ms
4,348 KB
testcase_20 AC 13 ms
9,408 KB
testcase_21 AC 14 ms
10,200 KB
testcase_22 AC 37 ms
24,252 KB
testcase_23 AC 88 ms
57,304 KB
testcase_24 AC 90 ms
58,096 KB
testcase_25 AC 13 ms
9,408 KB
testcase_26 AC 77 ms
50,508 KB
testcase_27 AC 25 ms
17,192 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17 // 4倍しても(4回足しても)long longを溢れない
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<int>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int n;
  cin >> n;
  vector<vector<ll>> dp(n + 10, vector<ll>(3, 0));
  dp[0][0] = 1; dp[1][0] = 1;
  for (int i = 0; i < n; ++i) {
    rep(j, 3) {
      rep(k, 3) {
        if (j == k) continue;
        int step = k + 1;
        dp[i + step][k] += dp[i][j] % MOD;
      }
    }
  }

  // rep(i, n + 1) cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << endl;

  ll ans = 0;
  rep(i, 3) ans += dp[n][i] % MOD;
  cout << ans % MOD << endl;
}
0