結果

問題 No.533 Mysterious Stairs
ユーザー realDivineJKrealDivineJK
提出日時 2020-05-28 18:21:31
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,037 ms / 5,000 ms
コード長 345 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 206,720 KB
最終ジャッジ日時 2024-04-21 06:23:53
合計ジャッジ時間 9,256 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 29 ms
10,752 KB
testcase_02 AC 26 ms
10,624 KB
testcase_03 AC 27 ms
10,624 KB
testcase_04 AC 28 ms
10,752 KB
testcase_05 AC 27 ms
10,880 KB
testcase_06 AC 27 ms
10,752 KB
testcase_07 AC 27 ms
10,752 KB
testcase_08 AC 27 ms
10,752 KB
testcase_09 AC 25 ms
10,624 KB
testcase_10 AC 26 ms
10,624 KB
testcase_11 AC 27 ms
10,752 KB
testcase_12 AC 27 ms
10,752 KB
testcase_13 AC 28 ms
10,880 KB
testcase_14 AC 27 ms
10,880 KB
testcase_15 AC 29 ms
10,880 KB
testcase_16 AC 31 ms
11,264 KB
testcase_17 AC 35 ms
11,648 KB
testcase_18 AC 41 ms
12,288 KB
testcase_19 AC 45 ms
12,544 KB
testcase_20 AC 221 ms
32,640 KB
testcase_21 AC 249 ms
35,200 KB
testcase_22 AC 744 ms
85,760 KB
testcase_23 AC 1,996 ms
204,288 KB
testcase_24 AC 2,037 ms
206,720 KB
testcase_25 AC 221 ms
32,640 KB
testcase_26 AC 1,720 ms
179,584 KB
testcase_27 AC 496 ms
60,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
mod = int(1e9) + 7
dp = [[0, 0, 0] for _ in range(N+1)]
for i in range(1, N+1):
    if i >= 1:
        dp[i][0] = (dp[i-1][1] + dp[i-1][2] + (i==1)) % mod
    if i >= 2:
        dp[i][1] = (dp[i-2][2] + dp[i-2][0] + (i==2)) % mod
    if i >= 3:
        dp[i][2] = (dp[i-3][0] + dp[i-3][1] + (i==3)) % mod
print(sum(dp[N]) % mod)
0