Catan
SRM 98 · 2002-06-14 · by axchma
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
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
20 21 Returns: 20
20 119 Returns: 20
20 121 Returns: 0
2 2 Returns: 1
2 3 Returns: 2
Submissions are judged against all 45 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class Catan with a public method long long sumCount(int numDice, int sum) · 45 test cases · 2 s / 256 MB per case