結果

問題 No.314 ケンケンパ
ユーザー takakintakakin
提出日時 2020-03-30 17:48:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 240 ms / 1,000 ms
コード長 335 bytes
コンパイル時間 257 ms
コンパイル使用メモリ 87,208 KB
実行使用メモリ 171,368 KB
最終ジャッジ日時 2023-09-04 05:47:07
合計ジャッジ時間 3,348 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 240 ms
171,316 KB
testcase_01 AC 71 ms
71,268 KB
testcase_02 AC 71 ms
71,444 KB
testcase_03 AC 70 ms
71,356 KB
testcase_04 AC 70 ms
71,276 KB
testcase_05 AC 70 ms
71,280 KB
testcase_06 AC 71 ms
71,132 KB
testcase_07 AC 69 ms
71,292 KB
testcase_08 AC 71 ms
71,452 KB
testcase_09 AC 70 ms
71,136 KB
testcase_10 AC 71 ms
71,244 KB
testcase_11 AC 72 ms
71,540 KB
testcase_12 AC 71 ms
71,072 KB
testcase_13 AC 72 ms
71,244 KB
testcase_14 AC 79 ms
76,492 KB
testcase_15 AC 79 ms
76,416 KB
testcase_16 AC 80 ms
76,644 KB
testcase_17 AC 83 ms
76,892 KB
testcase_18 AC 153 ms
120,692 KB
testcase_19 AC 238 ms
171,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
mod=10**9+7
if n==1:
  print(1)
else:
  D=[[0]*3 for _ in range(n)]
  D[1][0]=1
  D[1][1]=1
  D[1][2]=0
  for i in range(2,n):
    D[i][0]=D[i-1][2]
    D[i][1]=D[i-1][0]+D[i-1][2]
    if D[i][1]>mod:
      D[i][1]%=mod
    D[i][2]=D[i-1][1]
  print(sum(D[-1])%mod)
0