Dancing in Circles
Time limit3sMemory limit512 MB
Count ways to split n labeled children into k unordered directed cycles of length at least l, modulo 2005.
- Level
Hard8 of 10
- Topics
- Combinatorics, Math, Dynamic programming, Number theory
- Solved
- No attempts yet
Problem
A kindergarten is attended by children. Every day the children arrange themselves into circles and dance. Each circle must contain at least children.
Two arrangements are considered different if some child has a different right-hand neighbour in one arrangement than in the other. In other words, each circle is a directed ring in which every child has exactly one right neighbour, and the circles themselves are unordered.
Compute the number of distinct arrangements modulo . If no arrangement satisfies these conditions, the answer is .
Input
The first and only line contains three integers separated by single spaces: , , and .
- : the number of children ()
- : the number of circles ()
- : the minimum number of children in each circle ()
Output
Print, on a single line, the number of distinct arrangements modulo .