Want to solve this problem? Login now to get access to solve the problems

Problem

Submissions

Solution

Leaderboard

Coming soon

0

Difficulty: MEDIUM

Avg. time to solve

35 min

Success Rate

65%

Problem Statement

Suggest Edit

```
As the answer can be large, return your answer modulo 10^9 + 7.
```

```
Can you solve this using not more than O(S) extra space?
```

```
The first line of input contains an integer T denoting the number of queries or test cases.
The first and the only line of every test case contains 3 integers D, F and S representing the number of dices, the number of faces on each die and the target sum respectively.
```

```
For each test case, print the number of ways to get the sum S in a separate line.
```

```
You do not need to print anything, it has already been taken care of. Just implement the given function.
```

```
1 <= T <= 5
1 <= D <= 50
1 <= F <= 50
1 <= S <= 10^3
Time limit: 1 second
```

```
3
2 5 10
1 6 9
2 6 8
```

```
1
0
5
```

```
For test case 1:
We are given 2 dice with 5 faces numbered 1, 2, 3, 4 and 5.
The only possible way of getting a sum of 10 is when both the die face 5. Hence, the answer is 1.
For test case 2:
We are given 1 dice with 6 faces numbered 1, 2, 3, 4, 5 and 6.
There is no possible way of getting a sum of 9 with a single die having all the faces less than 9. Hence, the answer is 0.
For test case 3:
We are given 2 dice with 6 faces numbered 1, 2, 3, 4, 5 and 6.
The possible ways are [{2, 6}, {3, 5}, {4, 4}, {5, 3}, {6, 2}]. Hence, the answer is 5.
```

```
2
6 3 8
2 2 3
```

```
21
0
```

Want to solve this problem? Login now to get access to solve the problems