結果

問題 No.533 Mysterious Stairs
ユーザー treeonetreeone
提出日時 2017-06-23 22:47:11
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 41 ms / 5,000 ms
コード長 910 bytes
コンパイル時間 1,195 ms
コンパイル使用メモリ 158,436 KB
実行使用メモリ 26,752 KB
最終ジャッジ日時 2024-04-15 00:57:02
合計ジャッジ時間 2,100 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 1 ms
6,944 KB
testcase_02 AC 1 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 1 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,944 KB
testcase_07 AC 1 ms
6,944 KB
testcase_08 AC 2 ms
6,944 KB
testcase_09 AC 1 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 2 ms
6,944 KB
testcase_13 AC 2 ms
6,940 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 1 ms
6,940 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 2 ms
6,944 KB
testcase_20 AC 6 ms
6,940 KB
testcase_21 AC 6 ms
6,944 KB
testcase_22 AC 17 ms
12,416 KB
testcase_23 AC 41 ms
26,368 KB
testcase_24 AC 41 ms
26,752 KB
testcase_25 AC 6 ms
6,940 KB
testcase_26 AC 36 ms
23,424 KB
testcase_27 AC 12 ms
9,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define o(a) cout << a << endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef pair<int, int> P;

const int mod = 1e9 + 7;
int dp[1000010][3];

signed main(){
    int n;
    cin >> n;
    dp[1][0] = 1;
    dp[2][1] = 1;
    dp[3][2] = 1;
    // rep(i, 0, 3) dp[0][i] = 1;
    rep(i, 1, n + 1){
        rep(j, 0, 3){
            rep(k, 0, 3){
                if(j == k || i - (j + 1) < 0) continue;
                dp[i][j] = (dp[i][j] + dp[i - (j + 1)][k]) % mod; 
            }
        }
    }
    // rep(i, 0, n + 1){
    //     rep(j, 0, 3){
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    int ans = 0;
    rep(i, 0, 3) ans += dp[n][i];
    cout << ans % mod << endl;
}
0