Faint
Time limit1sMemory limit512 MB
Sum the absolute differences between consecutive rows of a fixed column in the lexicographically ordered list of k-subsets of {1,...,n}, modulo 1e9+7.
- Level
Hard8 of 10
- Topics
- Combinatorics, Math, Prefix sum, Implementation
- Solved
- No attempts yet
Problem
Consider the set of integers and all its subsets of size . Write each such subset as where . Write them down in lexicographical order, one per row, obtaining a table with rows and columns. Let the -th integer in the -th row be .
Your task is to calculate the sum of absolute differences between consecutive numbers in a given column. Formally, given a positive integer (), calculate the sum As the answer can be very large, print it modulo .
Input
The only line of input contains three positive integers , and ().
Output
Print a single line with a single integer: the answer to the problem modulo .
Hint
In the first example, the table looks as follows.
The answer is .