結果

問題 No.314 ケンケンパ
ユーザー asumo0729asumo0729
提出日時 2020-12-20 18:08:02
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,114 bytes
コンパイル時間 1,131 ms
コンパイル使用メモリ 81,648 KB
実行使用メモリ 420,608 KB
最終ジャッジ日時 2023-10-21 10:52:47
合計ジャッジ時間 4,934 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 sys
stdin=sys.stdin

ip=lambda: int(sp())
fp=lambda: float(sp())
lp=lambda:list(map(int,stdin.readline().split()))
tp=lambda:tuple(map(int,stdin.readline().split()))
sp=lambda:stdin.readline().rstrip()
yp=lambda:print('Yes')
np=lambda:print('No')

n=ip()
mod=10**9+7
dp=[[[[0 for _ in range(2)] for _ in range(2)] for _ in range(2)] for _ in range(10**6+10)]

if n>2:
    dp[3][0][0][0]=0
    dp[3][0][0][1]=1
    dp[3][0][1][0]=1
    dp[3][0][1][1]=0
    dp[3][1][0][0]=0
    dp[3][1][0][1]=0
    dp[3][1][1][1]=0
    dp[3][1][1][0]=0

    for i in range(4,10**6+10):
        dp[i][0][0][0]=0
        dp[i][0][0][1]=(dp[i-1][0][0][0]+dp[i-1][1][0][0])%mod
        dp[i][0][1][0]=(dp[i-1][0][0][1]+dp[i-1][1][0][1])%mod
        dp[i][0][1][1]=0
        dp[i][1][0][0]=(dp[i-1][0][1][0]+dp[i-1][0][1][1])%mod
        dp[i][1][0][1]=(dp[i-1][0][1][0]+dp[i-1][1][1][0])%mod
        dp[i][1][1][1]=0
        dp[i][1][1][0]=0

else:
    if n==1:
        print(1)
    else:
        print(2)
ans=0
for i in range(2):
    for j in range(2):
        for t in range(2):
            ans+=dp[n][i][j][t]

print(ans%mod)
0