Problem Statement
In the game "Settlers of Catan", a number of six-sided dice are rolled and their sum is calculated (each die is a cube with the numbers 1 through 6 on its faces). A useful statistic to know when playing the game is the number of possible ways to roll a given sum, with a given number of dice. For example, you can get the sum of 2 by rolling 2 dice in only one way: rolling 1 and 1. You can get the sum of 3 by rolling 2 dice in two ways: 1 on the first die and 2 on the second or vice versa.
Your task is write a class Catan, with a method sumCount, which takes an
Definition
- Class:
- Catan
- Method:
- sumCount
- Parameters:
- int, int
- Returns:
- long
- Method signature:
- long sumCount(int numDice, int sum)
- (be sure your method is public)
Notes
- The long data type is a 64-bit signed integer. Note for C++ coders: The long data type is specific to the gcc compiler.
Constraints
- numDice is between 1 and 20 inclusive
- sum is between 0 and 200 inclusive
Examples
20
21
Returns: 20
20
119
Returns: 20
20
121
Returns: 0
2
2
Returns: 1
2
3
Returns: 2
20
19
Returns: 0
5
29
Returns: 5
20
70
Returns: 189456975899496
5
0
Returns: 0
7
0
Returns: 0
20
20
Returns: 1
20
120
Returns: 1
11
10
Returns: 0
11
11
Returns: 1
11
12
Returns: 11
20
22
Returns: 210
20
118
Returns: 210
11
13
Returns: 66
11
64
Returns: 66
20
59
Returns: 68631941843000
20
71
Returns: 187890345960720
20
69
Returns: 187890345960720
1
1
Returns: 1
20
100
Returns: 52968655260
19
57
Returns: 14632730978909
20
72
Returns: 183266172913710
20
200
Returns: 0
20
99
Returns: 95473613400
20
174
Returns: 0
20
79
Returns: 96240548343540
20
160
Returns: 0
2
4
Returns: 3
20
90
Returns: 6040016957080
18
66
Returns: 5101926728031
20
110
Returns: 19852910
1
200
Returns: 0
20
74
Returns: 165858316337600
20
25
Returns: 42504
20
63
Returns: 125912390300660
2
2
Returns: 1
2
2
Returns: 1
2
2
Returns: 1
20
19
Returns: 0
5
29
Returns: 5
20
70
Returns: 189456975899496