結果

問題 No.314 ケンケンパ
ユーザー ryusukeryusuke
提出日時 2023-07-09 18:35:29
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 292 ms / 1,000 ms
コード長 461 bytes
コンパイル時間 494 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 173,772 KB
最終ジャッジ日時 2023-09-30 22:08:14
合計ジャッジ時間 3,593 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 288 ms
171,980 KB
testcase_01 AC 72 ms
71,604 KB
testcase_02 AC 72 ms
71,560 KB
testcase_03 AC 73 ms
71,092 KB
testcase_04 AC 72 ms
71,436 KB
testcase_05 AC 74 ms
71,380 KB
testcase_06 AC 73 ms
71,388 KB
testcase_07 AC 75 ms
71,288 KB
testcase_08 AC 73 ms
71,176 KB
testcase_09 AC 72 ms
71,444 KB
testcase_10 AC 72 ms
71,264 KB
testcase_11 AC 76 ms
75,624 KB
testcase_12 AC 78 ms
76,492 KB
testcase_13 AC 79 ms
76,344 KB
testcase_14 AC 79 ms
76,460 KB
testcase_15 AC 81 ms
76,624 KB
testcase_16 AC 82 ms
76,684 KB
testcase_17 AC 102 ms
87,420 KB
testcase_18 AC 187 ms
124,092 KB
testcase_19 AC 292 ms
173,772 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# verification-helper: PROBLEM https://yukicoder.me/problems/no/314

def main() -> None:
    n = int(input())
    
    dp = [[0] * 3 for _ in range(n + 1)]
    dp[1][1] = 1
    mod = 10**9 + 7

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

if __name__ == "__main__":
    main()
0