This page is still under construction.

Parts of this page are still being built. What you see may change.

School Canteen

Time limit5sMemory limit256 MB

Summary
Count length-n menus over k meals with no meal repeated l times in a row, modulo 4000000009.
Level

Medium7 of 10

Topics
Dynamic programming, Matrix, Combinatorics
Solved
No attempts yet

Problem

The cooks in a school canteen are always busy. They have to plan the menu for all nn days of the school year, and they can make only kk different meals.

The students are picky eaters. If the same meal is served on ℓ\ell days in a row, the students rebel against the cooks.

A menu assigns one meal to each of the nn days, and two menus are different if any single day gets a different meal. Count the menus that avoid a rebellion.

Input

The first line contains three space separated integers nn, ℓ\ell and kk. nn is the number of days (0≤n≤2 000 000 0000 \le n \le 2\,000\,000\,000), ℓ\ell is the impatience of the students, that is, how many repeats of a single meal in a row make them rebel (2≤ℓ≤2002 \le \ell \le 200), and kk is the number of possible meals (1≤k≤1001 \le k \le 100).

Output

Print on a single line the number of menus that avoid a rebellion, modulo 4 000 000 0094\,000\,000\,009. For n=0n = 0 the only menu is the empty one, so the answer is 11.

Hint

For n=3n = 3, ℓ=2\ell = 2 and k=3k = 3 there are exactly 12 menus with the required property.

1 2 1
1 2 3
1 3 1
1 3 2
2 1 2
2 1 3
2 3 1
2 3 2
3 1 2
3 1 3
3 2 1
3 2 3

Examples4

  1. Example 1

    Input
    3 2 3
    
    Expected output
    12
    
  2. Example 2

    Input
    0 2 1
    
    Expected output
    1
    
  3. Example 3

    Input
    1 200 100
    
    Expected output
    100
    
  4. Example 4

    Input
    7 4 3
    
    Expected output
    1944