結果

問題 No.533 Mysterious Stairs
ユーザー ああいいああいい
提出日時 2022-01-28 12:38:00
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 364 ms / 5,000 ms
コード長 383 bytes
コンパイル時間 323 ms
コンパイル使用メモリ 86,888 KB
実行使用メモリ 181,176 KB
最終ジャッジ日時 2023-08-28 09:02:38
合計ジャッジ時間 5,182 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,164 KB
testcase_01 AC 71 ms
71,152 KB
testcase_02 AC 71 ms
71,208 KB
testcase_03 AC 74 ms
71,180 KB
testcase_04 AC 70 ms
71,264 KB
testcase_05 AC 71 ms
71,252 KB
testcase_06 AC 71 ms
71,024 KB
testcase_07 AC 71 ms
71,208 KB
testcase_08 AC 71 ms
70,980 KB
testcase_09 AC 72 ms
71,060 KB
testcase_10 AC 82 ms
75,556 KB
testcase_11 AC 79 ms
76,040 KB
testcase_12 AC 81 ms
75,900 KB
testcase_13 AC 82 ms
76,244 KB
testcase_14 AC 87 ms
75,868 KB
testcase_15 AC 87 ms
76,348 KB
testcase_16 AC 89 ms
75,964 KB
testcase_17 AC 86 ms
76,148 KB
testcase_18 AC 84 ms
76,436 KB
testcase_19 AC 85 ms
76,384 KB
testcase_20 AC 121 ms
88,848 KB
testcase_21 AC 125 ms
90,480 KB
testcase_22 AC 201 ms
117,660 KB
testcase_23 AC 364 ms
180,004 KB
testcase_24 AC 360 ms
181,176 KB
testcase_25 AC 114 ms
88,916 KB
testcase_26 AC 318 ms
166,988 KB
testcase_27 AC 155 ms
103,960 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
dp = [[0] * 4 for _ in range(N+10)]

P = 10 ** 9 + 7
dp[1][1] = 1
dp[2][2] = 1
dp[3][3] = 1
for i in range(1,N+1):
    for j in range(1,4):
        if i + j <= N:
            for u in range(1,4):
                if u == j:continue
                else:
                    dp[i+j][j] = (dp[i+j][j] + dp[i][u]) % P
ans = dp[N][1] + dp[N][2] + dp[N][3]
print(ans % P)
0