結果

問題 No.554 recurrence formula
ユーザー ntudantuda
提出日時 2024-02-03 19:43:44
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 43 ms / 2,000 ms
コード長 203 bytes
コンパイル時間 415 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 61,200 KB
最終ジャッジ日時 2024-02-03 19:43:47
合計ジャッジ時間 2,554 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 36 ms
53,460 KB
testcase_03 AC 35 ms
53,460 KB
testcase_04 AC 35 ms
53,460 KB
testcase_05 AC 35 ms
53,460 KB
testcase_06 AC 35 ms
53,460 KB
testcase_07 AC 35 ms
53,460 KB
testcase_08 AC 35 ms
53,460 KB
testcase_09 AC 34 ms
53,460 KB
testcase_10 AC 40 ms
59,632 KB
testcase_11 AC 40 ms
59,600 KB
testcase_12 AC 39 ms
59,600 KB
testcase_13 AC 40 ms
59,592 KB
testcase_14 AC 40 ms
59,600 KB
testcase_15 AC 39 ms
59,592 KB
testcase_16 AC 40 ms
59,592 KB
testcase_17 AC 39 ms
59,592 KB
testcase_18 AC 39 ms
59,600 KB
testcase_19 AC 40 ms
61,200 KB
testcase_20 AC 43 ms
61,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7
n = int(input())
A = [0] * (n + 1)
B = [0] * (n + 1)
A[1] = 1
B[1] = 1
for i in range(2,n+1):
    A[i] = i * B[i-1]
    A[i] %= MOD
    B[i] = B[i-2] + A[i]
    B[i] %= MOD
print(A[n])
0