Bingo Game
Time limit1sMemory limit128 MB
Count N x N grids with distinct values from 1 to M, columns increasing downward, each column larger than all columns to its left, and total sum S, modulo 100000.
- Level
Hard8 of 10
- Topics
- Dynamic programming, Combinatorics, Prefix sum, Math
- Solved
- No attempts yet
Problem
At a certain programming contest, there is an unusual custom of playing a bingo game at the after-party. The "bingo card" used here is different from an ordinary bingo card: every cell must be filled so that all of the following conditions hold.
- The bingo card is an grid of cells, and each cell contains one integer. All of the integers are distinct.
- Each integer is between and inclusive.
- The sum of all integers is .
- In every column the values increase from top to bottom (each column is in ascending order).
- The integer in any cell must be greater than every integer in the columns to its left.
For example, when , , and , at least one bingo card satisfying these conditions exists. (Reading any column from top to bottom gives increasing values, and every value in a column is larger than all values in the columns to its left.)
Because many people want to attend the after-party, you want to make as many bingo cards as possible. However, everyone wants their own card, so no two cards may be identical. Print the maximum number of distinct bingo cards you can make, taken modulo .
Input
The input consists of one line containing three integers , , and separated by spaces: the card size (), the maximum integer allowed in a cell (), and the total sum of the integers on the card ().
For every given input, it is guaranteed that at least one bingo card satisfying the conditions can be made.
Output
Print, on a single line, the maximum number of distinct bingo cards that can be made, taken modulo .
Hint
For example, when , , and , the total number of bingo cards that can be made is , and .