結果

問題 No.533 Mysterious Stairs
ユーザー kokatsukokatsu
提出日時 2022-12-27 22:11:25
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 222 ms / 5,000 ms
コード長 496 bytes
コンパイル時間 4,087 ms
コンパイル使用メモリ 200,308 KB
実行使用メモリ 67,860 KB
最終ジャッジ日時 2023-09-04 19:29:16
合計ジャッジ時間 5,132 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 3 ms
4,384 KB
testcase_20 AC 22 ms
11,804 KB
testcase_21 AC 24 ms
11,860 KB
testcase_22 AC 70 ms
30,160 KB
testcase_23 AC 190 ms
67,860 KB
testcase_24 AC 222 ms
67,652 KB
testcase_25 AC 22 ms
10,732 KB
testcase_26 AC 167 ms
59,500 KB
testcase_27 AC 49 ms
20,116 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

enum long MOD = 10 ^^ 9 + 7;

void addMod(ref long x, long y) {
    x = (x + y) % MOD;
}

void main() {
    long N;
    readf("%d\n", N);

    auto dp = new long[][](N+1, 4);
    dp[0][0] = 1;
    foreach (i; 1.. N+1) {
        foreach (j; 1 .. 4) {
            if (j > i) continue;

            foreach (k; 0 .. 4) {
                if (k == j) continue;
                addMod(dp[i][j], dp[i-j][k]);
            }
        }
    }

    auto res = dp[N].sum % MOD;
    res.writeln;
}
0