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...
Top Software Developer Intern Interview Questions Asked at Microsoft Corporation
Q. What were your responsibilities during your internship?
Q. What is the difference between polymorphism and inheritance?
Q. Given a string, reverse the order of characters using standard data structures a...read more
Interview Questions Asked to Software Developer Intern at Other Companies
Top Skill-Based Questions for Microsoft Corporation Software Developer Intern
C++ Interview Questions and Answers
300 Questions
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Operating Systems Interview Questions and Answers
250 Questions
System Design Interview Questions and Answers
250 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

