結果

問題 No.533 Mysterious Stairs
ユーザー fumofumofunifumofumofuni
提出日時 2022-05-23 23:45:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 425 ms / 5,000 ms
コード長 402 bytes
コンパイル時間 674 ms
コンパイル使用メモリ 81,832 KB
実行使用メモリ 170,444 KB
最終ジャッジ日時 2023-10-20 17:48:05
合計ジャッジ時間 4,054 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,448 KB
testcase_01 AC 36 ms
53,448 KB
testcase_02 AC 37 ms
53,444 KB
testcase_03 AC 35 ms
53,444 KB
testcase_04 AC 34 ms
53,444 KB
testcase_05 AC 34 ms
53,444 KB
testcase_06 AC 35 ms
53,444 KB
testcase_07 AC 34 ms
53,444 KB
testcase_08 AC 35 ms
53,444 KB
testcase_09 AC 34 ms
53,444 KB
testcase_10 AC 41 ms
59,708 KB
testcase_11 AC 41 ms
62,048 KB
testcase_12 AC 47 ms
62,200 KB
testcase_13 AC 48 ms
64,248 KB
testcase_14 AC 47 ms
64,248 KB
testcase_15 AC 48 ms
64,344 KB
testcase_16 AC 51 ms
66,392 KB
testcase_17 AC 52 ms
68,440 KB
testcase_18 AC 53 ms
70,488 KB
testcase_19 AC 54 ms
72,536 KB
testcase_20 AC 102 ms
86,188 KB
testcase_21 AC 108 ms
87,524 KB
testcase_22 AC 203 ms
111,948 KB
testcase_23 AC 425 ms
169,264 KB
testcase_24 AC 415 ms
170,444 KB
testcase_25 AC 96 ms
86,264 KB
testcase_26 AC 378 ms
157,280 KB
testcase_27 AC 145 ms
99,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())

if N<=2:
    print(1)
    exit()

dp=[[0 for i in range(3)] for j in range(N+1)]
dp[1][0]=1
dp[2][1]=1
dp[3][2]=1

MOD=int(1e9+7)

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]
                dp[i+k+1][k]%=MOD

print((dp[N][0]+dp[N][1]+dp[N][2])%MOD)

0