結果

問題 No.314 ケンケンパ
ユーザー terrafarmterrafarm
提出日時 2020-12-14 09:08:39
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 934 bytes
コンパイル時間 125 ms
コンパイル使用メモリ 11,932 KB
実行使用メモリ 172,196 KB
最終ジャッジ日時 2023-10-20 04:47:38
合計ジャッジ時間 4,842 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import logging
import sys
from inspect import currentframe

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

logging.basicConfig(level=logging.DEBUG)


def dbg(*args):
    id2names = {id(v): k for k, v in currentframe().f_back.f_locals.items()}
    logging.debug(
        ", ".join(id2names.get(id(arg), "???") + " = " + repr(arg) for arg in args)
    )


def main():

    # 直前のケンの数で場合分け
    mod = 10 ** 9 + 7
    n = int(input())
    dp = [[0] * 3 for _ in range(n + 1)]
    dp[0][0] = 1
    for i in range(n):
        for j in range(3):
            if i == 0 and j != 0:
                continue
            for nj in range(3):
                if nj == (j + 1) % 3 or (j == 1 and nj == 0):
                    dp[i + 1][nj] += dp[i][j]
                    dp[i + 1][nj] %= mod
    s = 0
    for i in range(3):
        s += dp[n][i]
    s %= mod
    print(s)


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