CF1874E Jellyfish and Hack
题目描述
众所周知,快速排序通过随机选择一个“主元”元素,并根据其他元素是否小于或大于主元,将其划分为两个子数组。但 Jellyfish 认为选择随机元素只是浪费时间,所以她总是选择第一个元素作为主元。她的代码运行所需的时间可以通过以下伪代码计算:
```plain
function fun(A)
if A.length > 0
let L[1 ... L.length] and R[1 ... R.length] be new arrays
L.length = R.length = 0
for i = 2 to A.length
if A[i] < A[1]
L.length = L.length + 1
L[L.length] = A[i]
else
R.length = R.length + 1
R[R.length] = A[i]
return A.length + fun(L) + fun(R)
else
return 0
```
现在你想向她证明她的代码很慢。当函数 $ \mathrm{fun(A)} $ 大于等于 $ lim $ 时,她的代码将会“超时”。你想知道有多少个不同的 $ [1, 2, \dots, n] $ 的排列 $ P $ 满足 $ \mathrm{fun(P)} \geq lim $。由于答案可能很大,你只需要输出答案对 $ 10^9+7 $ 取模的结果。
输入格式
输入仅一行,包含两个整数 $ n $ 和 $ lim $($ 1 \leq n \leq 200 $,$ 1 \leq lim \leq 10^9 $)。
输出格式
输出满足条件的不同排列的数量,对 $ 10^9+7 $ 取模。
说明/提示
在第一个样例中,$ P = [1, 4, 2, 3] $ 满足条件,因为:$ \mathrm{fun(4, [1, 4, 2, 3]) = 4 + fun(3, [4, 2, 3]) = 7 + fun(2, [2, 3]) = 9 + fun(1, [3]) = 10} $。
请记得输出答案时对 $ 10^9+7 $ 取模。
由 ChatGPT 4.1 翻译