TopCoder problem "SchoolAssembly" used in TCO04 Round 2 (Division I Level One)



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

0)
    
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.
1)
    
1
2
Returns: 1
2)
    
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.
3)
    
223
15
Returns: 171

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=1119

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=5879&pm=1119

Writer:

schveiguy

Testers:

PabloGilberto , lbackstrom , vorthys

Problem categories:

Brute Force, Greedy