Count the number of ways to write as a sum of numbers from $1kge d$.
Problem
You are given three integers , , and . Count how many ordered sequences of positive integers satisfy all of the following:
- The sequence sum is exactly .
- Every element in the sequence is in the range .
- At least one element in the sequence is at least .
Because the answer can be large, return it modulo .
An ordered sequence means that different orders of the same numbers are considered different.
Goal
Compute the number of valid sequences.
Input Format
A single line contains three integers , , and .
Output Format
Print one integer — the number of valid sequences modulo .
Constraints
- Answer modulo
Example 1
Input
3 3 2
Output
3
Explanation
Valid ordered sequences are: [3], [1,2], and [2,1]. The sequence [1,1,1] is invalid because it contains no element at least 2.
Example 2
Input
3 3 3
Output
1
Explanation
Only [3] works. All other sequences sum to 3 but do not use any element at least 3, except [3] itself.
Premium problem context
Unlock deeper context for this problem
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.