結果

問題 No.314 ケンケンパ
ユーザー ryusukeryusuke
提出日時 2023-07-09 18:35:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 461 bytes
コンパイル時間 104 ms
コンパイル使用メモリ 10,912 KB
実行使用メモリ 204,456 KB
最終ジャッジ日時 2023-09-30 22:08:02
合計ジャッジ時間 6,101 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 AC 15 ms
7,988 KB
testcase_02 AC 15 ms
7,856 KB
testcase_03 AC 15 ms
7,876 KB
testcase_04 AC 15 ms
7,852 KB
testcase_05 AC 16 ms
7,952 KB
testcase_06 AC 15 ms
7,924 KB
testcase_07 AC 15 ms
7,856 KB
testcase_08 AC 15 ms
7,812 KB
testcase_09 AC 15 ms
7,860 KB
testcase_10 AC 16 ms
7,956 KB
testcase_11 AC 16 ms
7,916 KB
testcase_12 AC 16 ms
8,420 KB
testcase_13 AC 17 ms
8,420 KB
testcase_14 AC 22 ms
9,084 KB
testcase_15 AC 27 ms
10,164 KB
testcase_16 AC 43 ms
13,112 KB
testcase_17 AC 129 ms
27,984 KB
testcase_18 AC 626 ms
101,992 KB
testcase_19 TLE -
権限があれば一括ダウンロードができます

ソースコード

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