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 be
no arrangements satisfying the aforementioned conditions, the correct outcome is .
Task
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
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
The first and only line of the standard output should contain a single integer: .
Example
For the input data:
7 2 3
the correct result is:
420
Task author: Krzysztof Sikora.
Kontakt
W razie problemów technicznych ze Szkopułem, prosimy o kontakt mailowy pod adresem szkopul@fri.edu.pl.
Jeśli chciałbyś porozmawiać o zadaniach, rozwiązaniach lub problemach technicznych, odwiedź nasze serwery na Discordzie. Są one moderowane przez społeczność, ale członkowie zespołu wsparcia również aktywnie się tam udzielają.