結果

問題 No.314 ケンケンパ
ユーザー hang_hang_clnhang_hang_cln
提出日時 2018-06-15 00:21:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 353 ms / 1,000 ms
コード長 491 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 10,740 KB
実行使用メモリ 7,972 KB
最終ジャッジ日時 2023-09-13 04:25:39
合計ジャッジ時間 2,664 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 348 ms
7,916 KB
testcase_01 AC 16 ms
7,808 KB
testcase_02 AC 16 ms
7,864 KB
testcase_03 AC 16 ms
7,820 KB
testcase_04 AC 16 ms
7,864 KB
testcase_05 AC 16 ms
7,808 KB
testcase_06 AC 17 ms
7,820 KB
testcase_07 AC 16 ms
7,816 KB
testcase_08 AC 16 ms
7,876 KB
testcase_09 AC 16 ms
7,816 KB
testcase_10 AC 17 ms
7,848 KB
testcase_11 AC 17 ms
7,972 KB
testcase_12 AC 17 ms
7,800 KB
testcase_13 AC 17 ms
7,816 KB
testcase_14 AC 18 ms
7,808 KB
testcase_15 AC 20 ms
7,928 KB
testcase_16 AC 25 ms
7,908 KB
testcase_17 AC 49 ms
7,940 KB
testcase_18 AC 180 ms
7,784 KB
testcase_19 AC 353 ms
7,972 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def kenpa(n):
    if n == 1:
        return [1,0,0,0] # 終わり方が,ケンケンパ,ケンパケン,パケンケン,パケンパの順にメモ
    elif n == 2:
        return [1,1,0,0]
    elif n == 3:
        return [1,1,0,0]
    else:
        pre = kenpa(3)
        for i in range(n-3):
            ans = [pre[2]%1000000007,(pre[0]+pre[3])%1000000007,pre[1]%1000000007,pre[1]%1000000007]
            pre = ans
        return pre


N = int(input())
print(sum(kenpa(N))%(10**9+7))
0