Lecture Gap
View as PDF
Submit solution
Points:
100
Time limit:
1.0s
PyPy 3
3.0s
Python 3
3.0s
Memory limit:
500M
Problem type
You are scheduling lectures on days
. Let
be the day of the
-th
lecture. The days must satisfy
and consecutive lectures must be at least days apart:
for every . (In particular the sequence is automatically non-decreasing. If
, two
lectures may share a day.)
Count the number of integer sequences that meet these conditions. Since the answer can be
large, output it modulo
.
Input
A single line containing three integers ,
, and
.
Output
Print one integer: the number of valid lecture schedules, modulo .
Constraints
Example 1
Input
5 2 1
Output
10
Explanation
Consecutive lectures must fall on strictly later days. The valid pairs are all
, and there are
of them.
Example 2
Input
5 2 0
Output
15
Explanation
Now lectures may share a day, so the condition is . There are
such pairs.
Example 3
Input
5 1 10
Output
5
Explanation
A single lecture can be placed on any of the days. The gap
is unused when
.
Comments