Statistics

Problem Statement for "Catan"

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 int, numDice, and an int, sum, and returns the number of ways to roll sum using numDice. All of the dice are considered different, so to roll 1 on the first die and 3 on the second die is a different way to roll 4 than rolling 3 on the first die and 1 on the second die.

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

  1. 20

    21

    Returns: 20

  2. 20

    119

    Returns: 20

  3. 20

    121

    Returns: 0

  4. 2

    2

    Returns: 1

  5. 2

    3

    Returns: 2

  6. 20

    19

    Returns: 0

  7. 5

    29

    Returns: 5

  8. 20

    70

    Returns: 189456975899496

  9. 5

    0

    Returns: 0

  10. 7

    0

    Returns: 0

  11. 20

    20

    Returns: 1

  12. 20

    120

    Returns: 1

  13. 11

    10

    Returns: 0

  14. 11

    11

    Returns: 1

  15. 11

    12

    Returns: 11

  16. 20

    22

    Returns: 210

  17. 20

    118

    Returns: 210

  18. 11

    13

    Returns: 66

  19. 11

    64

    Returns: 66

  20. 20

    59

    Returns: 68631941843000

  21. 20

    71

    Returns: 187890345960720

  22. 20

    69

    Returns: 187890345960720

  23. 1

    1

    Returns: 1

  24. 20

    100

    Returns: 52968655260

  25. 19

    57

    Returns: 14632730978909

  26. 20

    72

    Returns: 183266172913710

  27. 20

    200

    Returns: 0

  28. 20

    99

    Returns: 95473613400

  29. 20

    174

    Returns: 0

  30. 20

    79

    Returns: 96240548343540

  31. 20

    160

    Returns: 0

  32. 2

    4

    Returns: 3

  33. 20

    90

    Returns: 6040016957080

  34. 18

    66

    Returns: 5101926728031

  35. 20

    110

    Returns: 19852910

  36. 1

    200

    Returns: 0

  37. 20

    74

    Returns: 165858316337600

  38. 20

    25

    Returns: 42504

  39. 20

    63

    Returns: 125912390300660

  40. 2

    2

    Returns: 1

  41. 2

    2

    Returns: 1

  42. 2

    2

    Returns: 1

  43. 20

    19

    Returns: 0

  44. 5

    29

    Returns: 5

  45. 20

    70

    Returns: 189456975899496


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: