This problem gave me a great deal of trouble when I first encountered it. I was able to figure out quickly enough that the answer to the maximum case is to make the largest team possible while putting as many participants in groups of size 1 to fulfill the requirement of having m groups. I also figured out that the solution for the minimum case was to put students in as "uniform" of groups as possible. It was figuring out how to put participants in these uniform groups which was the challenge!
In hindsight, my main difficulty was that I was lacking the interpretation of n % m necessary for this problem. The interpretation of n % m that has worked for me 99% of the time is the following:
n % m = m — (n/m)*m (1)
Intuitively, this interpretation of n % m can be computed by repeatedly summing m (i.e. n/m times) until it gets within m units of n and then calling the remainder n % m. Another way to view this procedure is that we are making as many groups from n pieces of size m out of n as we possibly can (i.e. n/m groups) and n % m represents the leftover pieces which don't belong to any of the groups.
This interpretation of n % m has always been sufficient for me. However, this problem demands the following interpretation of the quantity n % m:
n % m = m — m*(n/m) (2)
This equation looks almost identical to the one above, but it's computed in a very different way! Intuitively it is computed by making m groups, each of size n/m, from n pieces, and n % m is equal to the number of leftover pieces which don't get put in any group. If you are already familiar with this interpretation, then feel free to skip the following discussion. If not, then read on!
In order to explain equation (2), I am first going to illustrate equation (1) with an example. To this end, consider the quantity 8 % 3. We can write it down as follows:
8 % 3 = 8 — (3 + 3) + 2.
That is, we are able to make two groups of size 3, but we cannot make a third, so the number of leftover pieces (i.e. 8 % 3) is 2.
In the above example, out procedure for computing 8 % 3 was to make as many groups of size 3 as possible out of the 8 pieces. To understand equation (2), first consider the following interpretation of 8 / 3:
8 / 3 = 2.67 + 2.67 + 2.67 (3)
That is, we split 8 pieces into 3 groups and the quantity 8 / 3 represents the number of pieces in each group. Note we can manipulate the expression in (3) in the following way:
2.67 2.67 2.67 = (2.0 + 2.0 + 2.0) + (.67 + .67 + .67) = (2 + 2 + 2) + 2 = 3*2 + 2.
That is, we take strip off the decimal components of each of the group sizes and move them to the right. Notice that this now matches equation (2) exactly. That is, we have:
8 % 3 = 3*(8/3) + 2.
Even though this equation looks almost identical to equation (1), we computed it in a much different way!
Relating this back to the original problem, all that remains is to distribute the leftover n % m participants as evenly as possible into the m groups we've computed. It's not hard to see the way to do this is to add one student to each group until we run out of leftover participants. Thus we wind up with m total teams, n % m of which have size floor(n/m)+1 and m — n % m of which have size n / m.