結果

問題 No.533 Mysterious Stairs
ユーザー ThetaTheta
提出日時 2022-11-25 16:21:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 404 ms / 5,000 ms
コード長 503 bytes
コンパイル時間 392 ms
コンパイル使用メモリ 82,164 KB
実行使用メモリ 258,796 KB
最終ジャッジ日時 2024-04-09 22:58:46
合計ジャッジ時間 3,595 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
53,248 KB
testcase_01 AC 33 ms
51,816 KB
testcase_02 AC 33 ms
52,248 KB
testcase_03 AC 33 ms
53,324 KB
testcase_04 AC 32 ms
53,076 KB
testcase_05 AC 33 ms
53,204 KB
testcase_06 AC 33 ms
53,016 KB
testcase_07 AC 33 ms
53,552 KB
testcase_08 AC 32 ms
52,368 KB
testcase_09 AC 33 ms
53,940 KB
testcase_10 AC 34 ms
53,196 KB
testcase_11 AC 37 ms
59,200 KB
testcase_12 AC 41 ms
62,800 KB
testcase_13 AC 43 ms
62,244 KB
testcase_14 AC 43 ms
61,784 KB
testcase_15 AC 44 ms
62,996 KB
testcase_16 AC 45 ms
64,784 KB
testcase_17 AC 47 ms
66,148 KB
testcase_18 AC 47 ms
68,696 KB
testcase_19 AC 46 ms
71,204 KB
testcase_20 AC 88 ms
94,760 KB
testcase_21 AC 96 ms
98,488 KB
testcase_22 AC 193 ms
146,136 KB
testcase_23 AC 403 ms
255,036 KB
testcase_24 AC 404 ms
258,796 KB
testcase_25 AC 88 ms
95,068 KB
testcase_26 AC 360 ms
234,152 KB
testcase_27 AC 151 ms
122,128 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = int(1e9+7)


def main():
    N = int(input())
    dp_table = [[0, 0, 0, 0] for _ in range(N+1)]
    dp_table[0][0] = 1
    dp_table[0].append(sum(dp_table[0]) % MOD)
    for stair in range(1, N+1):
        for up_stair in range(1, min(stair+1, 4)):
            dp_table[stair][up_stair] = dp_table[stair-up_stair][4] - \
                dp_table[stair-up_stair][up_stair]
        dp_table[stair].append(sum(dp_table[stair]) % MOD)
    print(dp_table[N][4])


if __name__ == "__main__":
    main()
0