結果

問題 No.554 recurrence formula
ユーザー magurogumamaguroguma
提出日時 2017-09-24 00:53:54
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 414 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 14,592 KB
最終ジャッジ日時 2024-04-26 16:29:37
合計ジャッジ時間 1,830 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
11,392 KB
testcase_01 AC 29 ms
11,520 KB
testcase_02 AC 30 ms
11,392 KB
testcase_03 AC 30 ms
11,648 KB
testcase_04 AC 28 ms
11,392 KB
testcase_05 AC 29 ms
11,648 KB
testcase_06 AC 31 ms
11,392 KB
testcase_07 AC 30 ms
11,392 KB
testcase_08 AC 30 ms
11,392 KB
testcase_09 AC 30 ms
11,392 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

import sys

N = int(input())
M = 10**9 + 7

dp = [0] * (10**5 + 1)
def recurrence(n):
    if n==1:
        dp[n] = 1
    elif n==2:
        dp[n] = 2
    elif n==3:
        dp[n] = 6
    elif n==4:
        dp[n] = 28
    else:
        dp[n] = (n * (dp[n-2]//(n-2)%M + dp[n-1]%M)) % M
    return dp[n]

sys.setrecursionlimit(10**5+1)

for i in range(1, N+1):
    recurrence(i)

print(dp[N])
0