CF1874E.Jellyfish and Hack

NOI/NOI+/CTSC

通过率:0%

时间限制:8.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

It is well known that quick sort works by randomly selecting a 'pivot' element from the array and partitioning the other elements into two sub-arrays, according to whether they are less than or greater than the pivot. But Jellyfish thinks that choosing a random element is just a waste of time, so she always chooses the first element to be the pivot. The time her code needs to run can be calculated by the following pseudocode:

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

Now you want to show her that her code is slow. When the function fun(A)\mathrm{fun(A)} is greater than or equal to limlim, her code will get Time Limit Exceeded\text{Time Limit Exceeded}. You want to know how many distinct permutations PP of [1,2,…,n][1, 2, \dots, n] satisfies fun(P)≥lim\mathrm{fun(P)} \geq lim. Because the answer may be large, you will only need to find the answer modulo 109+710^9+7.

众所周知,快速排序通过从数组中随机选择一个“基准”(pivot)元素,并根据其余元素是否小于或大于该基准,将它们划分为两个子数组。但水母(Jellyfish)认为随机选取元素纯粹是浪费时间,因此她总是选择第一个元素作为基准。她的代码运行所需的时间可通过以下伪代码计算:

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

现在你想向她证明她的代码很慢。当函数 fun(A)\mathrm{fun(A)} 的值大于等于 limlim 时,她的代码将出现“超时”(Time Limit Exceeded)。你想知道:有多少个 [1,2,…,n][1, 2, \dots, n] 的不同排列 PP 满足 fun(P)≥lim\mathrm{fun(P)} \geq lim?由于答案可能很大,你只需输出结果对 109+710^9+7 取模的值。

输入格式

The only line of the input contains two integers nn and limlim (1≤n≤2001 \leq n \leq 200, 1≤lim≤1091 \leq lim \leq 10^9).

输入仅包含一行,其中有两个整数 nn 和 limlim(1≤n≤2001 \leq n \leq 200,1≤lim≤1091 \leq lim \leq 10^9)。

输出格式

Output the number of different permutations that satisfy the condition modulo 109+710^9+7.

输出满足条件的不同排列的数量,对 109+710^9+7 取模。

输入输出样例

  • 输入#1

    4 10

    输出#1

    8
  • 输入#2

    8 32

    输出#2

    1280

说明/提示

In the first example, P=[1,4,2,3]P = [1, 4, 2, 3] satisfies the condition, because: fun([1,4,2,3])=4+fun([4,2,3])=7+fun([2,3])=9+fun([3])=10\mathrm{fun([1, 4, 2, 3]) = 4 + fun([4, 2, 3]) = 7 + fun([2, 3]) = 9 + fun([3]) = 10}

Do remember to output the answer modulo 109+710^9+7.

在第一个例子中,P=[1,4,2,3]P = [1, 4, 2, 3] 满足条件,因为:fun([1,4,2,3])=4+fun([4,2,3])=7+fun([2,3])=9+fun([3])=10\mathrm{fun([1, 4, 2, 3]) = 4 + fun([4, 2, 3]) = 7 + fun([2, 3]) = 9 + fun([3]) = 10}

请注意,输出答案时需对 109+710^9+7 取模。

输入解题思路,AI测评打分。不知道怎么写?

首页