結果

問題 No.533 Mysterious Stairs
ユーザー NatsubiSoganNatsubiSogan
提出日時 2021-06-02 19:28:00
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,140 ms / 5,000 ms
コード長 378 bytes
コンパイル時間 222 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 206,848 KB
最終ジャッジ日時 2024-04-27 12:44:30
合計ジャッジ時間 9,466 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,752 KB
testcase_01 AC 26 ms
10,752 KB
testcase_02 AC 28 ms
10,752 KB
testcase_03 AC 28 ms
10,880 KB
testcase_04 AC 24 ms
10,752 KB
testcase_05 AC 24 ms
10,880 KB
testcase_06 AC 25 ms
10,880 KB
testcase_07 AC 26 ms
10,752 KB
testcase_08 AC 25 ms
10,752 KB
testcase_09 AC 26 ms
10,752 KB
testcase_10 AC 25 ms
10,880 KB
testcase_11 AC 25 ms
10,752 KB
testcase_12 AC 27 ms
10,880 KB
testcase_13 AC 26 ms
10,880 KB
testcase_14 AC 27 ms
11,008 KB
testcase_15 AC 28 ms
11,008 KB
testcase_16 AC 31 ms
11,264 KB
testcase_17 AC 41 ms
11,904 KB
testcase_18 AC 40 ms
12,288 KB
testcase_19 AC 43 ms
12,800 KB
testcase_20 AC 234 ms
32,768 KB
testcase_21 AC 262 ms
35,200 KB
testcase_22 AC 779 ms
85,888 KB
testcase_23 AC 2,093 ms
204,544 KB
testcase_24 AC 2,140 ms
206,848 KB
testcase_25 AC 237 ms
32,768 KB
testcase_26 AC 1,784 ms
179,712 KB
testcase_27 AC 493 ms
60,544 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
dp = [[0] * 3 for i in range(max(4, n + 1))]
dp[1][0] = 1; dp[2][1] = 1; dp[3][2] = 1
mod = 10 ** 9 + 7
for i in range(1, n + 1):
    dp[i][0] += dp[i - 1][1] + dp[i - 1][2]
    if i >= 2: dp[i][1] += dp[i - 2][0] + dp[i - 2][2]
    if i >= 3: dp[i][2] += dp[i - 3][0] + dp[i - 3][1]
    dp[i][0] %= mod; dp[i][1] %= mod; dp[i][2] %= mod
print(sum(dp[n]) % mod)
0