結果

問題 No.533 Mysterious Stairs
ユーザー brthyyjpbrthyyjp
提出日時 2021-03-23 14:06:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 330 ms / 5,000 ms
コード長 396 bytes
コンパイル時間 389 ms
コンパイル使用メモリ 81,904 KB
実行使用メモリ 172,448 KB
最終ジャッジ日時 2024-05-04 00:23:36
合計ジャッジ時間 3,987 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
51,968 KB
testcase_01 AC 39 ms
51,712 KB
testcase_02 AC 39 ms
51,584 KB
testcase_03 AC 38 ms
52,096 KB
testcase_04 AC 43 ms
52,352 KB
testcase_05 AC 39 ms
51,876 KB
testcase_06 AC 40 ms
52,480 KB
testcase_07 AC 40 ms
52,224 KB
testcase_08 AC 39 ms
51,712 KB
testcase_09 AC 39 ms
52,352 KB
testcase_10 AC 44 ms
58,496 KB
testcase_11 AC 47 ms
60,160 KB
testcase_12 AC 49 ms
61,696 KB
testcase_13 AC 48 ms
61,312 KB
testcase_14 AC 48 ms
61,312 KB
testcase_15 AC 49 ms
61,696 KB
testcase_16 AC 52 ms
62,336 KB
testcase_17 AC 52 ms
62,976 KB
testcase_18 AC 52 ms
63,872 KB
testcase_19 AC 52 ms
64,512 KB
testcase_20 AC 86 ms
87,040 KB
testcase_21 AC 90 ms
88,384 KB
testcase_22 AC 164 ms
113,648 KB
testcase_23 AC 330 ms
171,392 KB
testcase_24 AC 328 ms
172,448 KB
testcase_25 AC 87 ms
87,168 KB
testcase_26 AC 293 ms
159,568 KB
testcase_27 AC 128 ms
101,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
if n == 1:
    print(1)
    exit()
if n == 2:
    print(1)
    exit()
mod = 10**9+7
dp = [[0]*3 for i in range(n+1)]
dp[1][0] = 1
dp[2][1] = 1
dp[3][2] = 1

for i in range(n):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            if i+k+1 <= n:
                dp[i+k+1][k] += dp[i][j]%mod
#print(dp)
print(sum(dp[n])%mod)
0