結果

問題 No.314 ケンケンパ
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-06-30 10:43:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 89 ms / 1,000 ms
コード長 303 bytes
コンパイル時間 344 ms
コンパイル使用メモリ 86,932 KB
実行使用メモリ 76,288 KB
最終ジャッジ日時 2023-09-09 04:25:41
合計ジャッジ時間 2,696 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 89 ms
76,004 KB
testcase_01 AC 72 ms
71,352 KB
testcase_02 AC 73 ms
71,436 KB
testcase_03 AC 72 ms
71,340 KB
testcase_04 AC 73 ms
71,308 KB
testcase_05 AC 71 ms
71,392 KB
testcase_06 AC 70 ms
71,384 KB
testcase_07 AC 71 ms
71,304 KB
testcase_08 AC 71 ms
71,392 KB
testcase_09 AC 70 ms
71,320 KB
testcase_10 AC 72 ms
71,100 KB
testcase_11 AC 74 ms
71,320 KB
testcase_12 AC 74 ms
71,104 KB
testcase_13 AC 70 ms
71,300 KB
testcase_14 AC 76 ms
75,608 KB
testcase_15 AC 76 ms
75,792 KB
testcase_16 AC 74 ms
75,656 KB
testcase_17 AC 75 ms
75,936 KB
testcase_18 AC 81 ms
76,004 KB
testcase_19 AC 87 ms
76,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
mod=10**9+7
"""
dp[0]:パ -> 次はケンのみ
dp[1]:1個前がパで今ケン -> 次はケンとパ
dp[2]:2個前がパで今ケン -> 次はケンとパ
->dp[i]:ケンがi回続いている。
"""
dp=[0,1,0]
for _ in range(n-1):
  dp=[(dp[1]+dp[2])%mod,dp[0],dp[1]]
print(sum(dp)%mod)
0