結果

問題 No.314 ケンケンパ
ユーザー solzardsolzard
提出日時 2019-08-07 19:04:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 364 ms / 1,000 ms
コード長 479 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 10,676 KB
実行使用メモリ 63,024 KB
最終ジャッジ日時 2023-09-25 23:10:16
合計ジャッジ時間 2,770 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 359 ms
61,868 KB
testcase_01 AC 16 ms
7,780 KB
testcase_02 AC 16 ms
7,776 KB
testcase_03 AC 16 ms
7,904 KB
testcase_04 AC 16 ms
7,936 KB
testcase_05 AC 16 ms
7,892 KB
testcase_06 AC 17 ms
7,900 KB
testcase_07 AC 16 ms
7,880 KB
testcase_08 AC 16 ms
7,780 KB
testcase_09 AC 16 ms
7,884 KB
testcase_10 AC 17 ms
7,840 KB
testcase_11 AC 16 ms
7,840 KB
testcase_12 AC 16 ms
7,820 KB
testcase_13 AC 17 ms
7,888 KB
testcase_14 AC 19 ms
8,404 KB
testcase_15 AC 19 ms
8,648 KB
testcase_16 AC 25 ms
9,300 KB
testcase_17 AC 51 ms
13,548 KB
testcase_18 AC 184 ms
34,148 KB
testcase_19 AC 364 ms
63,024 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# No.314 ケンケンパ
def main():
    N = int(input())
    MOD = 10 ** 9 + 7
    # dp[i][j] := count on j-th position doing movement i
    dp = [[0] * N for _ in range(3)]
    dp[0][0] = 1
    for i in range(1, N):
        dp[0][i] = dp[2][i - 1]  # ケン
        dp[1][i] = dp[0][i - 1]  # ケンケン
        dp[2][i] = (dp[0][i - 1] + dp[1][i - 1]) % MOD  # パー
    ans = (dp[0][-1] + dp[1][-1] + dp[2][-1]) % MOD
    print(ans)


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