結果

問題 No.554 recurrence formula
ユーザー takakin
提出日時 2020-05-13 22:46:08
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 101 ms / 2,000 ms
コード長 319 bytes
コンパイル時間 163 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,624 KB
最終ジャッジ日時 2024-09-14 15:43:24
合計ジャッジ時間 1,654 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
e,o=0,1
mod=10**9+7
a=1
sig=0
for i in range(2,n+1):
  if sig==0:
    a=i*o
    if a>mod:
      a%=mod
    e+=a
    if e>mod:
      e%=mod
    sig=1
  else:
    a=i*e
    if a>mod:
      a%=mod
    o+=a
    if o>mod:
      o%=mod
    sig=0
print(a)
0