403764: GYM101262 D Vera and Sorting
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
D. Vera and Sortingtime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output
Vera is very smart and invented a new sorting algorithm. She coded the following python function to count how many steps her algorithm takes.
def steps(array):
if len(array) == 0:
return 0
pivot = array[0]
count = 0
lesser = []
greater = []
for element in array:
count += 1
if element < pivot:
lesser.append(element)
elif element > pivot:
greater.append(element)
return count + steps(lesser) + steps(greater)
A permutation P is an ordered set of integers P1, P2, ..., PN, consisting of N distinct positive integers, each of them doesn't exceed N. We'll call number N the size or the length of permutation.
You are given integers N and K.
Help Vera count the number of permutations P of size N such that steps(P) = K. This number could be large, so output it modulo 109 + 7.
Constraints:
1 ≤ N ≤ 30
1 ≤ K ≤ 900
N, K are integers
InputThe input will be in the format:
N K
OutputOutput one integer, the number of possible permutations, modulo 109 + 7.
ExamplesInput3 5Output
2Input
5 29Output
0Input
20 100Output
262859528Note
For the first example, the 2 valid permutations are 2, 1, 3 and 2, 3, 1.