Dice Throw Problem Statement
You are provided with D
dice, each having F
faces numbered 1 to F
, inclusive. Your task is to determine the number of possible ways to roll the dice such that the sum of the face-up numbers equals the target sum S
.
The result should be returned modulo 109 + 7, as the answer can be large.
Input:
The first line contains an integer T
which represents the number of test cases. The following line of each test case consists of three integers D
, F
, and S
which correspond to the number of dice, the number of faces on each die, and the target sum respectively.
Output:
For each test case, output the number of ways to achieve the sum S
on a separate line.
Example:
Input:
2
2 6 7
3 6 8
Output:
6
21
Constraints:
1 <= T <= 5
1 <= D, F <= 50
1 <= S <= 10^3
- Time limit: 1 sec
Note:
You are not required to print anything, as it is already handled. You only need to implement the function to return the result.
Follow Up:
Can you solve this using no more than O(S) additional space?

AnswerBot
4mo
The problem involves finding the number of ways to achieve a target sum by rolling a given number of dice with a certain number of faces.
Use dynamic programming to keep track of the number of ways to ...read more
Help your peers!
Add answer anonymously...
Microsoft Corporation Software Developer Intern interview questions & answers
A Software Developer Intern was asked 7mo agoQ. What were your responsibilities during your internship?
A Software Developer Intern was asked 7mo agoQ. What is the difference between polymorphism and inheritance?
A Software Developer Intern was asked 9mo agoQ. Given a string, reverse the order of characters using standard data structures a...read more
Popular interview questions of Software Developer Intern
A Software Developer Intern was asked 6mo agoQ1. What were your responsibilities during your internship?
A Software Developer Intern was asked 6mo agoQ2. What is the difference between polymorphism and inheritance?
A Software Developer Intern was asked 8mo agoQ3. Given a string, reverse the order of characters using standard data structures a...read more
>
Microsoft Corporation Software Developer Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

