P3445 [POI 2006] TAN-Dancing in Circles

Description

$n$ kids attend a certain kindergarten. Everyday the kids arrange themselves in $k$ circles and dance. At least $l$ 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 $2005$. Should there beno arrangements satisfying the aforementioned conditions, the correct outcome is $0$. Write a programme which: reads the numbers $n$, $k$ and $l$ from the standard input, calculates the number $d'=d \bmod 2005$, where $d$ denotes the number of distinct arrangements of the children ("$d \bmod 2005$" denotes the remainder of the division of $d$ by $2005$), writes $d'$ to the standard output.

Input Format

The first and only line of the standard input contains three integers separated by single spaces: $n$- the number of children ($3\le n\le 10^9$), $k$ - the number of circles ($1\le k\le n$) and $l$ - the minimal number of kids in a circle ($2\le l\le n$).

Output Format

The first and only line of the standard output should contain a single integer: $d \bmod2005$.