結果

問題 No.314 ケンケンパ
ユーザー Ryushi-techRyushi-tech
提出日時 2020-06-23 19:13:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 89 ms / 1,000 ms
コード長 278 bytes
コンパイル時間 248 ms
コンパイル使用メモリ 86,992 KB
実行使用メモリ 99,352 KB
最終ジャッジ日時 2023-09-16 20:04:01
合計ジャッジ時間 2,778 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
98,840 KB
testcase_01 AC 67 ms
71,148 KB
testcase_02 AC 69 ms
71,324 KB
testcase_03 AC 68 ms
71,348 KB
testcase_04 AC 69 ms
71,448 KB
testcase_05 AC 69 ms
71,416 KB
testcase_06 AC 69 ms
71,288 KB
testcase_07 AC 66 ms
71,468 KB
testcase_08 AC 66 ms
71,492 KB
testcase_09 AC 69 ms
71,128 KB
testcase_10 AC 68 ms
71,452 KB
testcase_11 AC 66 ms
71,344 KB
testcase_12 AC 67 ms
71,332 KB
testcase_13 AC 68 ms
71,144 KB
testcase_14 AC 72 ms
75,872 KB
testcase_15 AC 70 ms
76,088 KB
testcase_16 AC 72 ms
76,596 KB
testcase_17 AC 75 ms
78,236 KB
testcase_18 AC 80 ms
87,364 KB
testcase_19 AC 88 ms
99,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
mod = 10 ** 9 + 7
dp = [[0] * (n + 1) for _ in range(3)]
dp[1][0] = 1

for i in range(1, n + 1):
    dp[0][i] = (dp[1][i-1] + dp[2][i-1]) % mod
    dp[1][i] = dp[0][i-1] % mod
    dp[2][i] = dp[1][i-1] % mod

print((dp[0][n-1] + dp[1][n-1] + dp[2][n-1]) % mod)
0