結果

問題 No.314 ケンケンパ
ユーザー noriocnorioc
提出日時 2022-04-07 02:25:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 269 ms / 1,000 ms
コード長 468 bytes
コンパイル時間 422 ms
コンパイル使用メモリ 86,884 KB
実行使用メモリ 173,924 KB
最終ジャッジ日時 2023-08-18 15:27:07
合計ジャッジ時間 4,035 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 269 ms
172,328 KB
testcase_01 AC 71 ms
71,224 KB
testcase_02 AC 70 ms
71,188 KB
testcase_03 AC 71 ms
71,200 KB
testcase_04 AC 68 ms
71,288 KB
testcase_05 AC 67 ms
71,296 KB
testcase_06 AC 69 ms
71,284 KB
testcase_07 AC 70 ms
71,404 KB
testcase_08 AC 71 ms
71,376 KB
testcase_09 AC 68 ms
71,168 KB
testcase_10 AC 70 ms
71,472 KB
testcase_11 AC 74 ms
76,092 KB
testcase_12 AC 76 ms
76,572 KB
testcase_13 AC 76 ms
76,428 KB
testcase_14 AC 77 ms
76,680 KB
testcase_15 AC 79 ms
76,588 KB
testcase_16 AC 80 ms
76,664 KB
testcase_17 AC 100 ms
87,056 KB
testcase_18 AC 178 ms
124,232 KB
testcase_19 AC 268 ms
173,924 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
MOD = 10 ** 9 + 7

# dp[i][j]
# i 個目までみた
# j 個のケンが連続している
dp = [[0] * 3 for i in range(N)]
dp[0][1] = 1 # ケン
for i in range(N-1):
    # パ -> ケン
    dp[i+1][1] += dp[i][0]
    # ケン -> ケン
    dp[i+1][2] += dp[i][1]
    # ケン -> パ
    dp[i+1][0] += dp[i][1]
    # ケンケン -> パ
    dp[i+1][0] += dp[i][2]

    for j in range(3):
        dp[i+1][j] %= MOD

ans = sum(dp[N-1]) % MOD
print(ans)
0