Lecture Gap
You are scheduling k lectures on days 1,2,…,n. Let xi be the day of the i-th lecture. The days must satisfy
1≤x1,x2,…,xk≤n
and consecutive lectures must be at least g days apart:
xi+1≥xi+g
for every i. (In particular the sequence is automatically non-decreasing. If g=0, two lectures may share a day.)
Count the number of integer sequences x that meet these conditions. Since the answer can be large, output it modulo 109+7.
Input
A single line containing three integers n, k, and g.
Output
Print one integer: the number of valid lecture schedules, modulo 109+7.
Constraints
- 1≤k≤106
- 1≤n≤106
- 0≤g≤109
Example 1
5 2 1
10
Explanation
Consecutive lectures must fall on strictly later days. The valid pairs (x1,x2) are all 1≤x1<x2≤5, and there are (25)=10 of them.
Example 2
5 2 0
15
Explanation
Now lectures may share a day, so the condition is 1≤x1≤x2≤5. There are (25+2−1)=15 such pairs.
Example 3
5 1 10
5
Explanation
A single lecture can be placed on any of the 5 days. The gap g is unused when k=1.
Comments0
No comments yet
Be the first to comment.
New comment
Log in to join the discussion.