The "minimum" part of this problem was particularly challenging for me. I could see that we need to create m teams as "uniformly" as possible, but I was having a lot of trouble coming up with how to quantify that. This post explains the intuition behind distributing n people into m teams as uniformly as possible.
Note: as a matter of notation, the quantity n / m denotes integer truncating division throughout.
In hindsight, the reason this problem gave me so much trouble is because it demands an understanding of n % m that I did not possess initially. My tried and true understanding of n % m has always been the following:
n = (n/m)*m + n%m
In English, this can be read as "starting with n participants, we can form n/m teams, each with m participants, plus some leftover participants." However, this problem requires a fixed number of teams (i.e. m), so this interpretation will not do. With this in mind, we can rewrite Equation 1 as
n = m*(n/m) + n%m.
It may look like I've accomplished nothing with this rewrite, but it now can be read in a different way! We can now read it is "starting with n participants, we can form m teams, each with n/m participants, plus some leftover participants."
At this point, we have m teams which are uniform as can be (they all have an equal number of participants)! All that remains is to distribute the leftover participants as uniformly as possible into the m teams. It is not hard to see that the way to accomplish this is to add one participant to each team until we run out of leftover participants. As a result, we wind up with the following equation:
n = (n%m)*(n/m + 1) + (m — n%m)*(n/m).
This can be read as "starting with n participants, can form n % m teams, each having n/m + 1 participants, and m — n%m teams, each having n / m participants."