結果

問題 No.533 Mysterious Stairs
ユーザー fumofumofunifumofumofuni
提出日時 2022-05-23 23:45:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 409 ms / 5,000 ms
コード長 402 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 82,676 KB
実行使用メモリ 170,736 KB
最終ジャッジ日時 2024-09-20 13:25:46
合計ジャッジ時間 3,838 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
52,352 KB
testcase_01 AC 33 ms
52,096 KB
testcase_02 AC 38 ms
51,712 KB
testcase_03 AC 37 ms
51,968 KB
testcase_04 AC 34 ms
52,096 KB
testcase_05 AC 34 ms
51,840 KB
testcase_06 AC 35 ms
51,840 KB
testcase_07 AC 36 ms
52,224 KB
testcase_08 AC 36 ms
51,968 KB
testcase_09 AC 35 ms
51,968 KB
testcase_10 AC 40 ms
58,880 KB
testcase_11 AC 43 ms
60,800 KB
testcase_12 AC 52 ms
62,592 KB
testcase_13 AC 47 ms
62,848 KB
testcase_14 AC 49 ms
63,616 KB
testcase_15 AC 51 ms
64,384 KB
testcase_16 AC 49 ms
65,920 KB
testcase_17 AC 52 ms
68,224 KB
testcase_18 AC 57 ms
70,528 KB
testcase_19 AC 58 ms
72,064 KB
testcase_20 AC 104 ms
86,784 KB
testcase_21 AC 110 ms
87,960 KB
testcase_22 AC 191 ms
112,604 KB
testcase_23 AC 407 ms
169,916 KB
testcase_24 AC 409 ms
170,736 KB
testcase_25 AC 101 ms
86,808 KB
testcase_26 AC 363 ms
157,952 KB
testcase_27 AC 153 ms
99,968 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