結果

問題 No.533 Mysterious Stairs
ユーザー kappybarkappybar
提出日時 2020-05-22 12:42:44
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 91 ms / 5,000 ms
コード長 644 bytes
コンパイル時間 1,830 ms
コンパイル使用メモリ 168,408 KB
実行使用メモリ 57,904 KB
最終ジャッジ日時 2024-04-15 02:01:12
合計ジャッジ時間 2,672 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,944 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 2 ms
6,940 KB
testcase_10 AC 2 ms
6,944 KB
testcase_11 AC 1 ms
6,944 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,944 KB
testcase_17 AC 2 ms
6,944 KB
testcase_18 AC 2 ms
6,940 KB
testcase_19 AC 3 ms
6,944 KB
testcase_20 AC 12 ms
9,344 KB
testcase_21 AC 13 ms
9,984 KB
testcase_22 AC 35 ms
24,108 KB
testcase_23 AC 90 ms
57,288 KB
testcase_24 AC 91 ms
57,904 KB
testcase_25 AC 13 ms
9,472 KB
testcase_26 AC 77 ms
50,452 KB
testcase_27 AC 26 ms
17,012 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;


int main(){
    int n;
    cin >> n;
    vector<vector<ll>> dp(n,vector<ll>(3,0));
    rep(i,min(n,3)){
        dp[i][i] = 1;
    }
    rep(i,n){
        rep(j,3){
            if(i-j-1>=0){
                dp[i][j] = (dp[i-j-1][(j+1)%3] + dp[i-j-1][(j+2)%3])%MOD;
            }
        }
    }
    cout << (dp[n-1][0] + dp[n-1][1] + dp[n-1][2])%MOD << endl;
    return 0;
}
0