結果

問題 No.554 recurrence formula
ユーザー maspy
提出日時 2020-01-22 21:51:46
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 313 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 14,592 KB
最終ジャッジ日時 2024-07-16 02:45:45
合計ジャッジ時間 2,765 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(read())

MOD = 10**9 + 7

U = 10 ** 5
A = [0] * (U+1)
A[1] = 1

cum1 = 0
cum2 = 1
for x in range(2,U+1):
    cum1, cum2 = cum2, cum1
    A[x] = x * cum1 % MOD
    cum2 += A[x]

print(A[N])
0