Problem 478B

Правка en24, от ebanner, 2016-06-13 04:12:32

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 compute that. This post explains the intuition behind distributing n participants 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 initially possess. My tried and true understanding of n % m has always been

n = (n/m)*m + n%m.

In english, Equation 1 can be read as "starting with n participants, we can form n / m teams, each with m participants, plus some leftover participants." However, Problem 478B requires a fixed number of teams (i.e. m), so this interpretation will not do. With this in mind and by a twist of perspective, we can rewrite Equation 1 as

n = m*(n/m) + n%m.

It may look like we've accomplished nothing with this rewrite, but actually we can now read this in a more useful way! Concretely, Equation 2 can be read as "starting with n participants, we can form m teams, each with n / m participants, plus some leftover participants."

As a result, we now 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 each leftover participant to a different team. As a result of this process, we wind up with

n = (n%m)*(n/m + 1) + (m — n%m)*(n/m).

This can be read as "starting with n participants, we can form m teams. n % m of those teams have n/m + 1 participants in them (because there are n % m leftover participants). m — n%m of them (i.e. the rest) have n / m participants in them."

As an example, consider n = 8 and m = 3. Beginning with Equation 2, applying the procedure which follows, and arriving at Equation 3, we have

8 = (2 + 2 + 2) + 2 = (2+1 + 2+1 + 2) + 0 = 2*(2+1) + 1*2 = (8%3)*(8/3 + 1) + (3 — 8%3)*(8/3).

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en27 Английский ebanner 2016-08-14 17:35:13 39 Tiny change: 'rite, but actually we can no' - (published)
en26 Английский ebanner 2016-08-14 17:27:58 2 Tiny change: 'to create m teams as ' -> 'to create `m` teams as '
en25 Английский ebanner 2016-08-14 17:27:31 130 Tiny change: ' quantity n / m denotes i' - (saved to drafts)
en24 Английский ebanner 2016-06-13 04:12:32 3 Tiny change: 'cipant to different teams. As a res' -> 'cipant to a different team. As a res'
en23 Английский ebanner 2016-06-13 04:11:59 3 Tiny change: 'rticipants)! All that ' -> 'rticipants!). All that '
en22 Английский ebanner 2016-06-13 04:11:12 74 Tiny change: 'rite, but we can no' -
en21 Английский ebanner 2016-06-12 20:45:49 12 Tiny change: ' However, this problem requires ' -> ' However, Problem 478B requires '
en20 Английский ebanner 2016-06-12 20:44:53 2 Tiny change: '%m.\n\nIn English, Eq' -> '%m.\n\nIn english, Eq'
en19 Английский ebanner 2016-06-12 20:41:36 42 Tiny change: 'nd up with the following equation:\n\nn = (n' - (published)
en18 Английский ebanner 2016-06-12 20:38:51 140 Tiny change: ' English, this can be re' - (saved to drafts)
en17 Английский ebanner 2016-06-12 20:28:32 11 Tiny change: 'th how to quantify that. Thi' -> 'th how to compute that. Thi'
en16 Английский ebanner 2016-06-12 20:26:07 75
en15 Английский ebanner 2016-06-12 20:23:25 28
en14 Английский ebanner 2016-06-12 20:21:42 133 Tiny change: 'nts.
en13 Английский ebanner 2016-06-12 20:11:08 301 Tiny change: 'buting n people into m te' - (published)
en12 Английский ebanner 2016-06-12 19:58:36 2947 Tiny change: 'ially. My understan' - (saved to drafts)
en11 Английский ebanner 2016-06-12 18:59:07 87
en10 Английский ebanner 2016-06-12 18:54:04 57 Tiny change: 'ave:\n\n8 % 3 = 3*2 + 2' - (published)
en9 Английский ebanner 2016-06-12 18:45:19 531 Tiny change: 'possible. It was figu' -
en8 Английский ebanner 2016-06-12 17:50:02 776 Tiny change: '2 + 2.\n\nHere we stripped off the d' -
en7 Английский ebanner 2016-06-12 17:37:47 898 Tiny change: '; (n/m)*m _(1)_\n\n' -
en6 Английский ebanner 2016-06-12 17:12:48 2108 (saved to drafts)
en5 Английский ebanner 2016-06-12 00:02:01 693 Tiny change: 'ins is to the remaining n % m par' - (published)
en4 Английский ebanner 2016-06-11 23:50:24 1111 Tiny change: ' related, n % m als' -
en3 Английский ebanner 2016-06-11 23:35:23 523 Tiny change: '7 + .67)\n ' -
en2 Английский ebanner 2016-06-11 22:47:14 871
en1 Английский ebanner 2016-06-11 22:00:44 1291 Initial draft (saved to drafts)