Maxima
Time limit2sMemory limit1024 MB
Count permutations of 1 to n with exactly k maxima, where n is up to 10^15 and the answer is taken modulo 239.
- Level
Hard8 of 10
- Topics
- Combinatorics, Matrix, Dynamic programming
- Solved
- No attempts yet
Problem
A permutation of the integers from 1 to is said to have maxima if the inequality holds for exactly positions . Here .
For example, the permutation has two maxima: and .
Input
The input file contains two integers and (, ).
Output
Print one integer: the number of permutations of the integers from 1 to with exactly maxima, taken modulo 239.