#P3445. Kindergarten Dance Arrangements
Kindergarten Dance Arrangements
Kindergarten Dance Arrangements
In a kindergarten, there are \(n\) kids who form \(k\) circles to dance every day. In each circle, there must be at least \(l\) kids. Two arrangements are considered distinct if there is at least one kid whose right neighbour is different between the two arrangements.
For a valid arrangement, we partition the \(n\) kids into \(k\) groups (each of size \(m_i\ge l\)) and, in each circle, the number of distinct circular arrangements is \((m_i-1)!\) (since rotations are considered equivalent). Since the circles are unlabeled, the total number of arrangements is given by:
[ d = \frac{1}{k!}\sum_{\substack{m_1+m_2+\cdots+m_k=n\ m_i\ge l}} \frac{n!}{m_1m_2\cdots m_k}. ]
Your task is to compute \(d'\), where \(d' = d \bmod 2005\). If there is no valid arrangement, output 0.
Note: You can assume that \(n\), \(k\) and \(l\) are small enough for a complete search solution to work.
inputFormat
The input consists of three integers \(n\), \(k\) and \(l\) separated by spaces, representing the number of kids, the number of circles, and the minimum number of kids per circle, respectively.
outputFormat
Output a single integer: the value of \(d'\) (the number of distinct arrangements modulo 2005). If no valid arrangement exists, output 0.
sample
5 1 3
24