This page is still under construction.

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

Hosting MT

Time limit1sMemory limit256 MB

Summary
Count circular binary strings of length N, over all possible numbers of men from 0 to N, where no more than K men sit consecutively, modulo 10^8+7.
Level

Medium7 of 10

Topics
Combinatorics, Dynamic programming, Math, Implementation
Solved
No attempts yet

Problem

Taeyoung, now a sophomore in an engineering college, is preparing an MT for the incoming freshmen this year.

Everything else is ready, and only the 'random game', the highlight of an MT, remains to be prepared.

Taeyoung knows that N freshmen will enroll this year, but does not know how many of them are men and how many are women.

To run the game, Taeyoung plans to seat these N students around a round table.

After spending a year in an engineering college where women are relatively few, Taeyoung feels sorry about men sitting consecutively.

So Taeyoung made a rule: "More than K men cannot sit consecutively."

Find the number of ways to seat the N freshmen around the round table so that Taeyoung's rule is satisfied.

Since Taeyoung does not know how many of the N students are men, the number of men can be anything from 0 to N.

Also, since the freshmen sit around a round table, arrangements that are the same after rotation are treated as the same arrangement.

For example, if M denotes a man and W denotes a woman, MMWW, WWMM, and WMMW are all the same arrangement.

Input

The first line contains N and K in that order, separated by a space. (1 ≤ N, K ≤ 3000)

Note that K may be greater than N.

Output

Print the number of all seating arrangements that satisfy Taeyoung's rule. Since the answer can be very large, print it modulo 108+7.

Examples2

  1. Example 1

    Input
    4 2
    
    Expected output
    4
    
  2. Example 2

    Input
    3 2
    
    Expected output
    3