Practice Number of Dice Rolls With Target Sum
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
You have n dice, and each dice has k faces numbered from 1 to k. Given three integers n, k, and target, return the number of possible ways (out of the k^n total ways) to roll the dice, so the sum of the face-up numbers equals target. Since the answer may be too large, return it modulo 10^9 + 7.
Source: Number of Dice Rolls With Target Sum on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
n = 1, k = 6, target = 3
Output
1
# Example 2
Input
n = 2, k = 6, target = 7
Output
6
# Example 3
Input
n = 30, k = 30, target = 500
Output
222616187
Constraints
1 <= n, k <= 30
1 <= target <= 1000
Related LeetCode Problems
Practice more problems similar to Number of Dice Rolls With Target Sum.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.