結果

問題 No.314 ケンケンパ
ユーザー rlangevinrlangevin
提出日時 2023-01-07 14:00:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 97 ms / 1,000 ms
コード長 256 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 86,892 KB
実行使用メモリ 76,832 KB
最終ジャッジ日時 2023-08-21 04:57:25
合計ジャッジ時間 2,971 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
76,688 KB
testcase_01 AC 74 ms
71,468 KB
testcase_02 AC 74 ms
71,316 KB
testcase_03 AC 75 ms
71,080 KB
testcase_04 AC 74 ms
71,300 KB
testcase_05 AC 74 ms
71,112 KB
testcase_06 AC 73 ms
71,276 KB
testcase_07 AC 74 ms
71,424 KB
testcase_08 AC 75 ms
71,408 KB
testcase_09 AC 74 ms
71,284 KB
testcase_10 AC 73 ms
71,276 KB
testcase_11 AC 73 ms
71,276 KB
testcase_12 AC 75 ms
71,276 KB
testcase_13 AC 77 ms
71,152 KB
testcase_14 AC 80 ms
75,924 KB
testcase_15 AC 79 ms
76,136 KB
testcase_16 AC 79 ms
76,156 KB
testcase_17 AC 81 ms
76,020 KB
testcase_18 AC 89 ms
76,380 KB
testcase_19 AC 96 ms
76,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
mod = 10 ** 9 + 7
pre = [0, 1, 0]
for i in range(N - 1):
    dp = [0] * 3
    dp[0] += pre[1] + pre[2]
    dp[0] % mod
    dp[1] += pre[0]
    dp[1] %= mod
    dp[2] += pre[1]
    dp[2] %= mod
    
    dp, pre = pre, dp
print(sum(pre)%mod)
0