Statistics

Problem Statement for "SchoolAssembly"

Problem Statement

You are a director of a school, having an assembly for your kids. The assembly is on the topic of consistency, and as a demonstration, you want to hand out a number of jelly beans to each kid, and have all the jelly beans that an individual kid receives be the same color (one kid's color may be different than another kid's color). At the store, each bag of jelly beans contains exactly 20 beans, and each bean can be one of 5 colors. The bags are opaque, so you cannot determine ahead of time exactly how many of each color bean are in each bag (a bag could have any combination of the 5 colors, including 20 of one color). Given an int kids (the number of children) and an int quantity (the number of beans you want to give each kid), return how many bags of jelly beans you must buy to ensure that you have enough jelly beans to give each individual kid quantity same-colored beans.

Definition

Class:
SchoolAssembly
Method:
getBeans
Parameters:
int, int
Returns:
int
Method signature:
int getBeans(int kids, int quantity)
(be sure your method is public)

Constraints

  • kids will be between 1 and 1000, inclusive.
  • quantity will be between 2 and 25, inclusive.

Examples

  1. 1

    5

    Returns: 2

    Only one kid to buy for. Since the first bag you buy could contain 4 of each color, you must buy a second bag to ensure the child has 5 of the same color.

  2. 1

    2

    Returns: 1

  3. 5

    5

    Returns: 3

    If we buy 2 bags, we will be able to give 4 of the children 5 beans. However, we could be left with 4 beans of each color, requiring the third bag.

  4. 223

    15

    Returns: 171

  5. 1000

    25

    Returns: 1255

  6. 710

    25

    Returns: 893

  7. 88

    22

    Returns: 101

  8. 209

    18

    Returns: 192

  9. 419

    14

    Returns: 296

  10. 165

    20

    Returns: 169

  11. 406

    2

    Returns: 41

  12. 399

    19

    Returns: 383

  13. 919

    16

    Returns: 739

  14. 512

    17

    Returns: 439

  15. 59

    18

    Returns: 57

  16. 206

    12

    Returns: 126

  17. 757

    18

    Returns: 685

  18. 987

    8

    Returns: 397

  19. 833

    16

    Returns: 670

  20. 488

    13

    Returns: 320

  21. 484

    5

    Returns: 122

  22. 278

    7

    Returns: 99

  23. 526

    11

    Returns: 292

  24. 244

    6

    Returns: 75

  25. 576

    7

    Returns: 203

  26. 103

    20

    Returns: 107

  27. 656

    23

    Returns: 759

  28. 184

    16

    Returns: 151

  29. 39

    24

    Returns: 52

  30. 556

    3

    Returns: 84

  31. 663

    14

    Returns: 467

  32. 354

    6

    Returns: 108

  33. 93

    14

    Returns: 68

  34. 900

    15

    Returns: 678

  35. 596

    25

    Returns: 750

  36. 393

    23

    Returns: 457

  37. 936

    9

    Returns: 423

  38. 465

    24

    Returns: 563

  39. 172

    20

    Returns: 176

  40. 442

    21

    Returns: 469

  41. 476

    9

    Returns: 216

  42. 189

    6

    Returns: 58

  43. 690

    17

    Returns: 590

  44. 798

    6

    Returns: 241

  45. 631

    23

    Returns: 731

  46. 371

    13

    Returns: 244

  47. 410

    22

    Returns: 456

  48. 523

    15

    Returns: 396

  49. 404

    11

    Returns: 225

  50. 116

    16

    Returns: 96

  51. 47

    24

    Returns: 61

  52. 239

    3

    Returns: 37

  53. 459

    21

    Returns: 486

  54. 156

    19

    Returns: 152

  55. 593

    15

    Returns: 448

  56. 5

    10

    Returns: 5

  57. 1

    8

    Returns: 2

  58. 1000

    25

    Returns: 1255

  59. 999

    25

    Returns: 1254

  60. 13

    25

    Returns: 22

  61. 1

    25

    Returns: 7

  62. 25

    25

    Returns: 37

  63. 2

    4

    Returns: 1

  64. 1

    21

    Returns: 6

  65. 2

    7

    Returns: 2

  66. 23

    23

    Returns: 31

  67. 1

    20

    Returns: 5

  68. 3

    3

    Returns: 1

  69. 1

    18

    Returns: 5

  70. 8

    2

    Returns: 1

  71. 4

    3

    Returns: 1

  72. 571

    24

    Returns: 690

  73. 20

    25

    Returns: 30

  74. 6

    6

    Returns: 3


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: