Increasing Subsequences
Time limit4sMemory limit128 MB
Count permutations of 1..N whose longest increasing subsequence has length exactly B, modulo 1,000,000,000.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Combinatorics, Math
- Solved
- No attempts yet
Problem
A sequence made up of the numbers is called a permutation if all of its elements are distinct.
A permutation is said to contain an increasing subsequence of length when there exist indices such that .
When a permutation contains an increasing subsequence of length but does not contain one of length , the number is called the degree of increase of that permutation.
Given a number , write a program that counts the permutations whose degree of increase is exactly . Because this count can be very large, output its remainder modulo .
Input
The input consists of a single line containing two integers and (, ), separated by one or more spaces.
Output
Output a single integer: the number of permutations whose degree of increase is exactly , taken modulo .