Logo
(追記) (追記ここまで)

15442번 - Vera and Sorting 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 256 MB18161386.667%

문제

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: ## looks at each element in the array
 count += 1
 if element < pivot:
 lesser.append(element) ## e.g. [1,3].append(5) => [1,3,5]
 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 which are at most N. We will call the number N the size of the permutation.

You are given integers N and K.

Help Vera count the number of permutations P of size N such that steps(P) returns the value K. This number could be large, so output it modulo 109 + 7.

입력

The input will be in the format:

N K

Constraints:

  • 1 ≤ N ≤ 30
  • 1 ≤ K ≤ 900
  • N, K are integers

출력

Output one integer, the number of possible permutations, modulo 109 + 7.

제한

예제 입력 1

3 5

예제 출력 1

2

예제 입력 2

5 29

예제 출력 2

0

예제 입력 3

20 100

예제 출력 3

262859528

힌트

For the first example, the 2 valid permutations are 2, 1, 3 and 2, 3, 1.

출처

Contest > Waterloo's local Programming Contests > 4 March, 2017 D번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /