結果

問題 No.533 Mysterious Stairs
ユーザー hiro71687khiro71687k
提出日時 2023-03-31 02:43:45
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 158 ms / 5,000 ms
コード長 749 bytes
コンパイル時間 4,194 ms
コンパイル使用メモリ 264,908 KB
実行使用メモリ 73,708 KB
最終ジャッジ日時 2023-10-23 16:12:55
合計ジャッジ時間 6,234 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 1 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 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 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 3 ms
4,348 KB
testcase_18 AC 4 ms
4,348 KB
testcase_19 AC 3 ms
4,348 KB
testcase_20 AC 20 ms
11,292 KB
testcase_21 AC 23 ms
12,084 KB
testcase_22 AC 62 ms
30,360 KB
testcase_23 AC 155 ms
72,916 KB
testcase_24 AC 158 ms
73,708 KB
testcase_25 AC 21 ms
11,292 KB
testcase_26 AC 136 ms
64,008 KB
testcase_27 AC 41 ms
21,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using ld=long double;
ld pie=3.141592653589793;
ll mod=1000000007;
ll inf=999999999999999999;
int main(){
    ll n;
    cin >> n;
    vector<vector<ll>>dp(n+10,vector<ll>(4,0));
    dp[1][1]=1;
    dp[2][2]=1;
    dp[3][3]=1;
    for (ll i = 1; i < n; i++)
    {
        for (ll j = 1; j <= 3; j++)
        {
            for (ll k = 1; k <= 3; k++)
            {
                if (j==k)
                {
                    continue;
                }
                dp[i+k][k]+=dp[i][j];
                dp[i+k][k]%=mod;
            }
        }
    }
    ll ans=dp[n][1]+dp[n][2]+dp[n][3];
    ans%=mod;
    cout << ans << endl;
}
0