#P3445. [POI 2006] TAN-Dancing in Circles
[POI 2006] TAN-Dancing in Circles
Description
kids attend a certain kindergarten. Everyday the kids arrange themselves in circles and dance.
At least kids dance in each circle. Two arrangements of children are considered distinct if there is a child who has a different right neighbour in one of the arrangements than in the other.
Your task is to calculate the number of all distinct arrangements modulo . Should there beno arrangements satisfying the aforementioned conditions, the correct outcome is .
Write a programme which:
reads the numbers , and from the standard input, calculates the number , where denotes the number of distinct arrangements of the children ("" denotes the remainder of the division of by ), writes to the standard output.
Input Format
The first and only line of the standard input contains three integers separated by single spaces: - the number of children (), - the number of circles () and - the minimal number of kids in a circle ().
Output Format
The first and only line of the standard output should contain a single integer: .
7 2 3
420
京公网安备 11011102002149号