Imagine you're at a board game night with n dice, and each die has k faces numbered from 1 to k. Your challenge is to find how many different ways you can roll these dice so that the sum of all face-up numbers equals a specific target.
For example, with 2 dice (each having 6 faces) and a target sum of 7, you could roll (1,6), (2,5), (3,4), (4,3), (5,2), or (6,1) - that's 6 different ways!
The Goal: Count all possible combinations of dice rolls that sum to the target value.
Input: Three integers n (number of dice), k (faces per die), and target (desired sum)
Output: Number of ways to achieve the target sum, modulo 109 + 7 (since the result can be very large)
Note: With n dice having k faces each, there are kn total possible outcomes, but we only want those that sum to our target!
Input & Output
Constraints
- 1 โค n โค 30
- 1 โค k โค 30
- 1 โค target โค 1000
- Return result modulo 109 + 7