KBTU Party
Time limit2sMemory limit128 MB
Count the ways to choose r disjoint acquainted girl-boy pairs when girl j knows exactly the first 2j-1 boys, modulo 2946859.
- Level
Hard8 of 10
- Topics
- Combinatorics, Dynamic programming, Math, Number theory
- Solved
- No attempts yet
Problem
At the KBTU graduation party there are girls and boys . Girl is acquainted with exactly the boys (the first boys).
We want to pick exactly dancing pairs. Each pair consists of one girl and one boy who are acquainted, and no student may belong to more than one pair (every girl and every boy appears in at most one chosen pair). Count the number of ways to choose such a set of pairwise-disjoint acquainted pairs. Two choices are considered different if their sets of pairs differ.
Input
Two integers and () separated by a space.
Output
Print the number of ways, taken modulo .