16

You are organizing a party. However, the number of guests to attend your party can be anything from $a_1$, $a_2$, $\ldots$, $a_n$, where the $a_i$'s are positive integers. You want to be prepared, so you want to cut a cake into smaller pieces. The pieces are not necessarily of equal size. The requirement is that, no matter how many guests come (which you will have known before distributing the cake), you will be able to give each of them some pieces of the cake without having to cut the cake any further so that everybody will get the same amount of cake. What is the minimum number of pieces of your cake you will have to cut it into?

Trivially, if $n=1$, then the answer is $a_1$. The answer is also known for $n=2$, which is $a_1+a_2-\gcd\left(a_1,a_2\right)$ (if you wonder why graph theory is in the tag, it is because the only proof known to me for the $n=2$ case is done via a graph-theorical argument). I conjecture that the answer, in general, is $$m:=\sum_{j=1}^n\,(-1)^{j-1}\,g_j\,,$$ where $$g_j:=\sum_{1\leq k_1<k_2<\ldots<k_j\leq n}\,\gcd\left(a_{k_1},a_{k_2},\ldots,a_{k_j}\right)$$ for $j=1,2,\ldots,n$ (here, $g_1$ is simply $a_1+a_2+\ldots+a_n$). It is easy to cut the cake into $m$ pieces to satisfy the required condition.

Apparently, the conjecture is false for $n>2$ (see Dividing the whole into a minimal amount of parts to equally distribute it between different groups.). However, I expect that my guess is not far away from the correct answer.

EDIT: The $n=2$ case with $\gcd\left(a_1,a_2\right)=1$ appeared as a problem for the Spring Contest, A Level, of the Tournament of the Towns of 1990. See https://keoserey.files.wordpress.com/2012/12/imtot-book-3.pdf (page 35 of the PDF).

Related Topics:

Dividing the whole into a minimal amount of parts to equally distribute it between different groups.

https://puzzling.stackexchange.com/questions/19870/nine-gangsters-and-a-gold-bar/19881#19881

https://mathoverflow.net/questions/214477/minimal-possible-cardinality-of-a-a-1-a-k-distributable-multiset

Batominovski
  • 50,341
  • 2
    What's it with cakes today?! –  Aug 03 '15 at 20:03
  • 2
    I got reminded about this problem by the other cake question (that one wants to maximize things). Why don't you contribute another cake problem, so we'll have a proper cake party? – Batominovski Aug 03 '15 at 20:04
  • 2
    @BolzWeir: They're like yawns, I think. :-) – Brian Tung Aug 03 '15 at 20:07
  • 1
    @Batominovski: Actually, I asked yet another cake question, which has nothing to do with maximizing anything, really. So it's already a cake party. – Brian Tung Aug 03 '15 at 20:07
  • Well, cake or no cake I must be misreading it. Isn't the answer obviously the lcm? How does that formula work for 2 possibilities? If I know that either $2$ or $3$ people will show up then clearly I need $6$ pieces of cake, no? The formula yields $4$. Well, I expect I am misreading. Low blood sugar, no doubt. – lulu Aug 03 '15 at 20:31
  • 1
    For $n=2$, $a_1=2$, and $a_2=3$, you can do the job by cutting the cake into $4$ pieces. Think carefully. I never said that these pieces must be of equal size. – Batominovski Aug 03 '15 at 20:38
  • 6
    Can we create a tag for cakes? – Batominovski Aug 03 '15 at 20:41
  • Got it, thanks. Good problem! – lulu Aug 03 '15 at 20:53
  • Your conjectured expression looks awfully like some inclusion-exclusion computation. Care to share the reasoning behind the $n = 2$ case? – vonbrand Aug 07 '15 at 22:52
  • @vonbrand Because, to get $m$, I used the Principle of Inclusion and Exclusion. Hence, the resemblance is not astonishing. I can post the $n=2$ case tomorrow, if you want. – Batominovski Aug 07 '15 at 22:54
  • Didn't this problem originally include the case 3, 4, 5, with answer 9? I think I can prove $3,4,n$ with $\gcd(n,6)=1$ can be done with $n+4$ pieces. – Gerry Myerson Aug 08 '15 at 11:19
  • @GerryMyerson I don't know where this problem came from, so I have no idea what the problem originally included. If you wouldn't mind, could you please write an answer to the $3,4,n$ case? – Batominovski Aug 08 '15 at 11:25
  • I have trouble believing that, for the $3,4,n$ case, you only need $n+4$ pieces. It will have to require more pieces than the $4,n$ case, which already needs $n+4-1=n+3$ pieces. Hence, $n+4$ is a lower bound, but I'm pretty sure it is not sharp. – Batominovski Aug 08 '15 at 14:41
  • @dtldarek But I'm asking about the number of pieces, not the number of cuts. There shouldn't be any ambiguity. And Gerry Myerson said: "… can be done with $n+4$ *pieces*." – Batominovski Aug 08 '15 at 15:17
  • @Batominovski You are right, I misread. – dtldarek Aug 08 '15 at 15:49
  • 1
    I found the other question: http://math.stackexchange.com/questions/1381042/dividing-the-whole-into-a-minimal-amount-of-parts-to-equally-distribute-it-betwe (and I wonder how it is that two people independently posted essentially the same question at pretty much the same time --- where does the question actually come from?). – Gerry Myerson Aug 09 '15 at 00:51
  • @GerryMyerson Thanks. That counterexample is surprising. I was asked the $n=2$ case long time ago (I think by a friend). I don't know if this problem has been asked anywhere else. – Batominovski Aug 09 '15 at 01:32
  • 2
    I've made a puzzle out of the case (7,8,9), check it out: http://puzzling.stackexchange.com/questions/19870/nine-gangsters-and-a-gold-bar/19881#19881 I figured out an explicit solution with 19 pieces, but I have a strong suspicion that it can be done at least with 18. I also described this problem in general in MO: http://mathoverflow.net/questions/214477/minimal-possible-cardinality-of-a-a-1-a-k-distributable-multiset – Glinka Aug 11 '15 at 12:07
  • I think you ought to provide links at puzzling to the questions here and at MO. – Gerry Myerson Aug 12 '15 at 07:21

2 Answers2

10

Here is a sketch of the proof that if $\gcd(n,6)=1$ then you can satisfy $3$, $4$, or $n$ guests with $n+4$ pieces.

We imagine the cake to be of size $12n$. We cut it into $n-4$ pieces, each of size $12$, and what's left over gets cut into eight pieces, of sizes $1,2,4,5,7,8,10,11$, making $n+4$ pieces all told, as promised.

Now we can certainly share the cake equally among $n$ guests: $n-4$ of them get a single piece of size $12$, and each of the other four guests get $11+1$, or $10+2$, or $8+4$, or $7+5$.

If we have four guests, we want to split the cake into four portions, each of size $3n$. If we distribute the $n-4$ size $12$ pieces among our four guests as evenly as possible, we will either have three guests with $3n-9$, and one guest with $3n-21$, or we will have three guests with $3n-15$ and one guest with $3n-3$. [Of course, this assertion requires checking, but it really is a simple matter of considering the cases $n=4k+1$ and $n=4k+3$, and doing the arithmetic.] In the first case, we make up the deficit with $8+1$, $7+2$, $5+4$, and $11+10$. In the second case, with $11+4$, $10+5$, $8+7$, and $2+1$.

Finally, if we have three guests, we want to split the cake into three portions, each of size $4n$. Again, distribute the $n-4$ size $12$ pieces as evenly as possible. We wind up with three guests at $4n-16$, or else with two guests at $4n-20$ and one guest at $4n-8$ [and again I leave it to you to check the arithmetic here]. In the first case, we bring all the guests up to $4n$ by distributing $11+5$, $10+4+2$, and $8+7+1$. In the second case, $11+5+4$, $10+8+2$, $7+1$.

EDIT: I think more generally if $3<a<b$ are pairwise coprime, then you can keep $3$, $a$, or $b$ guests happy with $a+b$ pieces. I won't try to write a proof, just present an example with $a\ne4$.

For $3,5,7$, let the cake have size $3\times5\times7=105$. Split the cake in seven pieces of size $15$, then split five of those pieces into $1$ and $14$, $2$ and $13$, $4$ and $11$, $5$ and $10$, $7$ and $8$ (that's all the possible splits, avoiding only those not prime to $3$). All told, $5+7=12$ pieces.

Sharing among seven guests is obvious.

Sharing among five guests is accomplished by $15+5+1$, $15+4+2$, $14+7$, $13+8$, $11+10$.

Sharing among three guests is accomplished by $15+15+5$, $14+13+8$, $11+10+7+4+2+1$.

We can also do $4,5,7$ in twelve pieces, using two $20$s and each odd number from $1$ to $19$, inclusive.

Gerry Myerson
  • 185,413
  • Thanks a lot for this reply. Could you please also try the $5,6,7$ case? I expect that cutting into $13$ pieces works. I think, at least, there should be a pattern for the $6k-1,6k,6k+1$ case. – Batominovski Aug 09 '15 at 12:07
  • 1
    I can do $5,6,7$ with $14$ pieces: $30,29, 26, 24, 21, 19, 16,14,11,9,4,4,2,1$. I don't know whether it can be done with $13$. – Gerry Myerson Aug 10 '15 at 03:27
  • How did you come up with these numbers? I can't find a strategy to get them. – Batominovski Aug 10 '15 at 15:48
  • 1
    I drew a circular cake of circumference $210$. I sliced it at $0,30,60,90,120,150,180$, making seven sectors of $30$ each. Then I made six equally spaced slices, at $1,36,71,106,141,176$, so now I have $13$ pieces and I can satisfy six or seven guests. Playing with the $13$ numbers, I can make three portions of size $42$, but the remaining pieces don't make the two additional portions of size $42$ that I need. But if I take a sector of size $6$ (the one between the cuts at $30$ and $36$, and cut it into a $4$ and a $2$, then I can make the other two $42$s, and I'm done. – Gerry Myerson Aug 10 '15 at 23:57
  • 1
    Even without complete answer, your reply provides me a great set of counterexamples to my conjecture. Thanks, and the bounty award goes to you. – Batominovski Aug 13 '15 at 21:18
  • 1
    @Batominovski For, 5,6,7, optimal is 13 pieces: 3, 5, 8, 10, 12, 13, 17, 18, 20, 22, 25, 27, 30 – RobPratt Feb 10 '25 at 19:14
9

This is a proof for the case where $n=2$, as requested by vonbrand.

Consider a bipartite graph graph $G\left(V_1\cup V_2,E\right)$, where $V_1$ and $V_2$ are bipartite sets with $\left|V_1\right|=a_1$ and $\left|V_2\right|=a_2$ such that they represent the guests who may attend the party and $\left\{v_1,v_2\right\}$ with $v_1 \in V_1$ and $v_2\in V_2$ are in the edge set $E$ if and only if there exists a piece of this cake that will be given to $v_1$ if $a_1$ guests come such that this same piece will be given to $v_2$ if $a_2$ guests come. Clearly, we need at least $|E|$ pieces of cake. We shall verify that $|E|\geq a_1+a_2-d$, where $d:=\gcd\left(a_1,a_2\right)$. It suffices to show that there are at most $d$ connected components in $G$.

Suppose that $C$ is a connected component of $G$. Write $C_1$ for the set of vertices of $C$ in $V_1$ and $C_2$ for the set of vertices of $C$ in $V_2$. Each guest in $V_1$ takes $\frac{1}{a_1}$ amount of cake, while each guest in $V_2$ takes $\frac{1}{a_2}$ amount of cake. Hence, the total amount of cake given to guests in $C_1$ is $\frac{\left|C_1\right|}{a_1}$, while the total amount of cake given to guests in $C_2$ is $\frac{\left|C_2\right|}{a_2}$. Since $C$ is a connected component, guests in $C_1$ must consume the same amount of cake as that consumed by guests in $C_2$; otherwise, there will be an edge going from $C_1$ or $C_2$ to a vertex outside $C$. Ergo, we must have that $$\frac{\left|C_1\right|}{a_1}=\frac{\left|C_2\right|}{a_2}\text{ or }\frac{a_2}{d}\left|C_1\right|=\frac{a_1}{d}\left|C_2\right|\,.$$ Hence, $\frac{a_1}{d}$ divides $\left|C_1\right|$, as $\gcd\left(\frac{a_1}{d},\frac{a_2}{d}\right)=1$. Thence, $\left|C_1\right| \geq \frac{a_1}{d}$ (and similarly, $\left|C_2\right| \geq \frac{a_2}{d}$).

Consequently, every connected component of $G$ has at least $\frac{a_1}{d}$ vertices in $V_1$. Hence, $G$ can have at most $d$ connected components. The proof is now complete.

P.S. You can probably see why this sort of arguments won't work for $n>2$. If we try to create $n$-partite graphs in the same way, then the number of pieces of cake is related to the number of $n$-cliques of this graph. However, not all $n$-cliques can be assigned to a piece of cake, and two distinct pieces of cake can produce two non-identical, but non-disjoint, $n$-cliques. Hence, for $n>2$, I think we need a completely new way to solve the problem. We might be able to use $n$-uniform hypergraphs in tackling the case $n>2$.

Batominovski
  • 50,341