Valentine's Day '18 S3 - Carol's Cactesian Conquest

View as PDF

Submit solution

Points: 17 (partial)
Time limit: 1.0s
Memory limit: 512M

Author:
Problem type

Carol wants to win Cactus' heart, so she has planned a magnificent trip to the land of Cartesia together. Unfortunately, Cactus is not very interested in the modern art and hiking trails, nor Cartesia's mystical scripture of calculating time complexity. He is more preoccupied with solving an abstract algorithm problem. Carol decides to solve the following problem for him.

A contiguous subsequence of an array is a sequence of numbers at indices i, i+1, \dots, j of the array. An increasing contiguous subsequence of an array is a contiguous subsequence where a[i] < a[i+1] < \dots < a[j].

Cactus would like to know the number of permutations of the elements 1 to N where the maximum length increasing contiguous subsequence has length K.

Constraints

1 \le K \le N \le 100

Subtask 1 [7/15]

N \le 35

Subtask 2 [8/15]

No additional constraints.

Input Specification

The first line will contain N and K.

Output Specification

Output the number of permutations of the elements 1 to N which has maximum contiguous increasing subsequence with length K, mod 10^9+7.

Sample Input 1

5 3

Sample Output 1

41

Sample Input 2

10 8

Sample Output 2

231

Sample Input 3

1 1

Sample Output 3

1

Comments

There are no comments at the moment.