Woburn Challenge 2015-16 Round 1 - Junior Division

Problem 2: Grouping Recruits

Now that you know a little more about Woburn, let's learn a bit more about the amazing computer science enrichment opportunity that it holds. You might not know that every couple of years, Woburn's very own Programming Enrichment Group recruits elementary and middle school students who aspire to be talented little computer scientists. Indeed, training programmers from such a young age has been a key principle behind the club's success.

Since the number of recruits is usually very high, the PEG leader(s) will often have trouble handling them alone and all at once. Thus, an age-old solution has been devised – splitting them up into groups, each of which will be taught by a senior member of the club! However, this is a more challenging task than it seems, since senior members tend to complain amongst themselves about how unfair it is that some of them have to deal with teaching significantly more recruits than others.

Let's say that there are N recruits and M senior members within the club (1 ≤ MN ≤ 100). We would like to "evenly" divide the N recruits up into M groups such that the numbers of recruits the senior members have to handle are roughly equal to each other. More precisely, we would like to split up the recruits into M groups such that the difference between the size of the largest group and the size of the smallest group is as small as possible. Only this way can we prevent certain senior members from complaining that their duty is too hard and unfair compared to other senior members.

Please help PEG divide the recruits into "fair" groups.

Input Format

The first line of input will contain a single integer N representing the number of recruits to be split up.
The second line of input will contain a single integer M representing the number of groups that must be made.

Output Format

Output one line for each group size in the format "X group(s) of Y" where Y is the size of the group and X is the number of groups with this size in your grouping scheme.
You may output the lines in any order. Consult the sample outputs if you need further clarification of the format.

Sample Input 1


Sample Output 1

3 group(s) of 10

Explanation 1

There are 30 recruits and three senior members. We can just do three nice groups of 10 recruits each.

Sample Input 2


Sample Output 2

4 group(s) of 4
1 group(s) of 5

Explanation 2

There are 21 recruits and five senior members. The fairest option would be to create four groups of 4 and one group of 5 (where the difference between the smallest and largest group is 5 − 4 = 1).
This is more "fair" than, for instance, creating four groups of 5 and one group of 1 (where the difference between the largest and smallest group sizes is 5 − 1 = 4).

All Submissions
Best Solutions

Point Value: 5
Time Limit: 2.00s
Memory Limit: 16M
Added: Oct 17, 2015
Authors: Alex, SourSpinach

Languages Allowed:

Comments (Search)

wow, you did it!