結果

問題 No.533 Mysterious Stairs
ユーザー kcz146kcz146
提出日時 2020-12-07 00:18:46
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 92 ms / 5,000 ms
コード長 1,024 bytes
コンパイル時間 2,173 ms
コンパイル使用メモリ 206,380 KB
実行使用メモリ 73,548 KB
最終ジャッジ日時 2023-10-17 15:43:00
合計ジャッジ時間 3,670 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 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
11,132 KB
testcase_21 AC 14 ms
11,924 KB
testcase_22 AC 37 ms
30,200 KB
testcase_23 AC 92 ms
72,756 KB
testcase_24 AC 90 ms
73,548 KB
testcase_25 AC 13 ms
11,132 KB
testcase_26 AC 80 ms
63,848 KB
testcase_27 AC 26 ms
21,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// UTF−8

#include<bits/stdc++.h>
/* #include<atcoder/all> */
/* using namespace atcoder; */

using namespace std;
using ll = long long int;
using lc = complex<ll>;

template<class T>bool chmax(T &a, const T &b) { return (a<b ? (a=b,1) : 0); }
template<class T>bool chmin(T &a, const T &b) { return (a>b ? (a=b,1) : 0); }

int main(void) {
    constexpr ll MOD = 1 ? 1e9+7 : 998244353;
    constexpr double PI = acos(-1);
    constexpr double eps = 1e-10;
    cout << fixed << setprecision(32);
    cin.tie(0); ios::sync_with_stdio(false);

    if(1) {
        ll n;
        cin >> n;
        vector<vector<ll>> dp(n+5, vector<ll>(4));

        dp[1][1] = dp[2][2] = dp[3][3] = 1;
        for(ll i=0; i<=n; i++) {
            if(i-1>=0) dp[i][1] += (dp[i-1][2] + dp[i-1][3]) % MOD;
            if(i-2>=0) dp[i][2] += (dp[i-2][1] + dp[i-2][3]) % MOD;
            if(i-3>=0) dp[i][3] += (dp[i-3][2] + dp[i-3][1]) % MOD;
        }
        cout << (dp[n][1] + dp[n][2] + dp[n][3]) % MOD << endl;
    }

    return 0;
}
0