Browse · MathNet
PrintInternational Mathematical Olympiad
counting and probability
Problem
Let be a positive integer. We start with piles of pebbles, each initially containing a single pebble. One can perform moves of the following form: choose two piles, take an equal number of pebbles from each pile and form a new pile out of these pebbles. For each positive integer , find the smallest number of non-empty piles that one can obtain by performing a finite sequence of moves of this form.
Solution
We can combine two piles of pebbles to make one pile of pebbles. In particular, given piles of one pebble, we may combine them as follows: This proves the desired result in the case when is a power of .
If is not a power of , choose such that . Let . Then . Make a pile of pebbles and call it the large pile. (Alternatively, one can be more efficient and make a pile of pebbles where .) Since is not a power of two, there is at least one other pile with pebbles. All other piles have a single pebble (initial condition).
Choose one single pebble pile and remove the pebble and one pebble from the large pile and form a pile of pebbles. If , remove another pebble from the large pile and one pebble from the -pile and form a new pile of pebbles. Repeat until the large pile contains exactly pebbles.
At this point we have one pile of pebbles, one pile of pebbles, and the rest are single pebble piles. There must be single piles. Combine two and two into piles of two pebbles. Then there are piles of two pebbles, which we can make into one pile of pebbles. We are left with exactly two piles of pebbles.
Lastly we will prove that it is not possible to form a single pile with all pebbles when is not a power of two. A move consists of choosing two piles of say and pebbles, then removing pebbles from both piles, and forming a new pile with pebbles. If we include piles of zero pebbles, then this move changes the number of pebbles in three piles as follows (and leaves all other piles unchanged): Assume that after the move the number of pebbles in each pile is divisible by an odd integer . In particular, and . Since is odd, it follows that , and then that and . Hence also before the move the number of pebbles in each pile is divisible by the integer .
If is not a power of , then is divisible by an odd integer . In order to make a single pile of pebbles, we would have to start with a distribution in which the number of pebbles in each pile is divisible by the integer . This is impossible when we start with all piles containing a single pebble.
---
Alternative solution.
We show an alternative strategy if is not a power of . Write in binary form: , where . Now we make piles of sizes . We call the pile with the large pile, all the others are the small piles.
The strategy is the following: take the two smallest small piles. If they have the same size of , we make a pile of size . If they have different sizes, we double the smaller pile using the large pile (we allow the large pile to have a negative number of pebbles: later we prove that it is not possible). We call all the new piles small. When we have only one small pile, we terminate the process: we have at most piles.
After each move we have one less number of piles, and all the piles have cardinality power of . The number of pebbles is decreasing, and at the end of the process, it has a size of , thus we can manage to have two piles.
---
Alternative solution.
Throughout the solution, we will consider the moves in reverse order. Namely, imagine we have some piles of pebbles, and we are allowed to perform moves as follows: take a pile with an even number of pebbles, split it into two equal halves and add the pebbles from each half to a different pile, possibly forming new piles (we may assume for convenience that there are infinitely many empty piles at any given moment). Given a configuration of piles , we will use to denote the number of non-empty piles in . Given two configurations , we will say that is reachable from if can be obtained by performing a finite sequence of moves starting from .
Call a configuration of piles - simple if each (non-empty) pile in consists of a single pebble; - good if at least one (non-empty) pile in has an even number of pebbles and the numbers of pebbles on the piles in have no non-trivial odd common divisor ( has the odd divisor property); - solvable if there exists a simple configuration which is reachable from .
The problem asks to find the smallest number of non-empty piles in a solvable configuration consisting of pebbles. We begin the process of answering this question by making the following observation:
Lemma 1. Let be a configuration of piles. Let be a configuration obtained by applying a single move to . Then (i) if has the odd divisor property, then so does ; (ii) the converse to (i) holds if .
Proof. Suppose that the move consists of splitting a pile of size and adding pebbles to each of two piles of sizes and . Here, is a positive integer and are non-negative integers. Thus, can be obtained from by replacing the piles of sizes by two piles of sizes and . Note that the extra assumption of part (ii) holds if and only if at least one of is zero.
(i) Suppose doesn't have the odd divisor property, i.e. there exists an odd integer such that the size of each pile in is divisible by . In particular, are multiples of , so since is odd, it follows that are all divisible by . Thus, and are also divisible by , so divides the size of each pile in . In conclusion, doesn't have the odd divisor property.
(ii) If doesn't have the odd divisor property and at least one of is zero, then there exists an odd integer such that the size of each pile in is divisible by . In particular, divides and , so since at least one of these numbers is equal to , it follows that divides . But then must divide all three of and , and hence it certainly divides and . Thus, doesn't have the odd divisor property, as desired.
Lemma 2. If is reachable from and has the odd divisor property, then so does . In particular, any solvable configuration has the odd divisor property.
Proof. The first statement follows by inductively applying part (i) of Lemma 1. The second statement follows from the first because every simple configuration has the odd divisor property.
The main claim is the following:
Lemma 3. Let be a good configuration. Then there exists a configuration with the following properties: - is reachable from and ; - is either simple or good.
Proof. Call a configuration terminal if it is a counterexample to the claim. The following claim is at the heart of the proof:
Claim. Let be the numbers of pebbles on the non-empty piles of a terminal configuration . Then there exists a unique such that is even. Moreover, for all we have for all .
Proof of Claim. Since the configuration is good, there must exist such that is even. Moreover, by assumption, if we split the pile with pebbles into two equal halves, the resulting configuration will not be good. By part (ii) of Lemma 2, the only way this can happen is that and for all are odd. To prove the second assertion, we proceed by induction on , with the case already being established. If , then split the pile with pebbles into two equal halves and move one half to the pile with pebbles. Since and are both odd, is even, so by part (ii) of Lemma 2, the resulting configuration is good. Thus, is terminal, so by the induction hypothesis, we have , whence , as desired.
Suppose for contradiction that there exists a configuration as in the Claim. It follows that there exists and an odd integer such that and for all . Thus, is an odd common divisor of , so by the odd divisor property, we must have . But then we can obtain a simple configuration by splitting the only pile with two pebbles into two piles each consisting of a single pebble, which is a contradiction.
With the aid of Lemmas 2 and 3, it is not hard to characterise all solvable configurations:
Lemma 4. A configuration of piles is solvable if and only if it is simple or good.
Proof. () Suppose is not simple. Then since we have to be able to perform at least one move, there must be at least one non-empty pile in with an even number of pebbles. Moreover, by Lemma 2, has the odd divisor property, so it must be good.
() This follows by repeatedly applying Lemma 3 until we reach a simple configuration. Note that the process must stop eventually since the number of non-empty piles is bounded from above.
Finally, the answer to the problem is implied by the following corollary of Lemma 4:
Lemma 5. Let be a positive integer. Then (i) a configuration consisting of a single pile of pebbles is solvable if and only if is a power of two; (ii) if , then the configuration consisting of piles of sizes and is good.
Proof. (i) By Lemma 4, this configuration is solvable if and only if either or is even and has no non-trivial odd divisor, so the conclusion follows.
(ii) Since is even and has no non-trivial odd divisor, this configuration is certainly good, so the conclusion follows by Lemma 4.
If is not a power of , choose such that . Let . Then . Make a pile of pebbles and call it the large pile. (Alternatively, one can be more efficient and make a pile of pebbles where .) Since is not a power of two, there is at least one other pile with pebbles. All other piles have a single pebble (initial condition).
Choose one single pebble pile and remove the pebble and one pebble from the large pile and form a pile of pebbles. If , remove another pebble from the large pile and one pebble from the -pile and form a new pile of pebbles. Repeat until the large pile contains exactly pebbles.
At this point we have one pile of pebbles, one pile of pebbles, and the rest are single pebble piles. There must be single piles. Combine two and two into piles of two pebbles. Then there are piles of two pebbles, which we can make into one pile of pebbles. We are left with exactly two piles of pebbles.
Lastly we will prove that it is not possible to form a single pile with all pebbles when is not a power of two. A move consists of choosing two piles of say and pebbles, then removing pebbles from both piles, and forming a new pile with pebbles. If we include piles of zero pebbles, then this move changes the number of pebbles in three piles as follows (and leaves all other piles unchanged): Assume that after the move the number of pebbles in each pile is divisible by an odd integer . In particular, and . Since is odd, it follows that , and then that and . Hence also before the move the number of pebbles in each pile is divisible by the integer .
If is not a power of , then is divisible by an odd integer . In order to make a single pile of pebbles, we would have to start with a distribution in which the number of pebbles in each pile is divisible by the integer . This is impossible when we start with all piles containing a single pebble.
---
Alternative solution.
We show an alternative strategy if is not a power of . Write in binary form: , where . Now we make piles of sizes . We call the pile with the large pile, all the others are the small piles.
The strategy is the following: take the two smallest small piles. If they have the same size of , we make a pile of size . If they have different sizes, we double the smaller pile using the large pile (we allow the large pile to have a negative number of pebbles: later we prove that it is not possible). We call all the new piles small. When we have only one small pile, we terminate the process: we have at most piles.
After each move we have one less number of piles, and all the piles have cardinality power of . The number of pebbles is decreasing, and at the end of the process, it has a size of , thus we can manage to have two piles.
---
Alternative solution.
Throughout the solution, we will consider the moves in reverse order. Namely, imagine we have some piles of pebbles, and we are allowed to perform moves as follows: take a pile with an even number of pebbles, split it into two equal halves and add the pebbles from each half to a different pile, possibly forming new piles (we may assume for convenience that there are infinitely many empty piles at any given moment). Given a configuration of piles , we will use to denote the number of non-empty piles in . Given two configurations , we will say that is reachable from if can be obtained by performing a finite sequence of moves starting from .
Call a configuration of piles - simple if each (non-empty) pile in consists of a single pebble; - good if at least one (non-empty) pile in has an even number of pebbles and the numbers of pebbles on the piles in have no non-trivial odd common divisor ( has the odd divisor property); - solvable if there exists a simple configuration which is reachable from .
The problem asks to find the smallest number of non-empty piles in a solvable configuration consisting of pebbles. We begin the process of answering this question by making the following observation:
Lemma 1. Let be a configuration of piles. Let be a configuration obtained by applying a single move to . Then (i) if has the odd divisor property, then so does ; (ii) the converse to (i) holds if .
Proof. Suppose that the move consists of splitting a pile of size and adding pebbles to each of two piles of sizes and . Here, is a positive integer and are non-negative integers. Thus, can be obtained from by replacing the piles of sizes by two piles of sizes and . Note that the extra assumption of part (ii) holds if and only if at least one of is zero.
(i) Suppose doesn't have the odd divisor property, i.e. there exists an odd integer such that the size of each pile in is divisible by . In particular, are multiples of , so since is odd, it follows that are all divisible by . Thus, and are also divisible by , so divides the size of each pile in . In conclusion, doesn't have the odd divisor property.
(ii) If doesn't have the odd divisor property and at least one of is zero, then there exists an odd integer such that the size of each pile in is divisible by . In particular, divides and , so since at least one of these numbers is equal to , it follows that divides . But then must divide all three of and , and hence it certainly divides and . Thus, doesn't have the odd divisor property, as desired.
Lemma 2. If is reachable from and has the odd divisor property, then so does . In particular, any solvable configuration has the odd divisor property.
Proof. The first statement follows by inductively applying part (i) of Lemma 1. The second statement follows from the first because every simple configuration has the odd divisor property.
The main claim is the following:
Lemma 3. Let be a good configuration. Then there exists a configuration with the following properties: - is reachable from and ; - is either simple or good.
Proof. Call a configuration terminal if it is a counterexample to the claim. The following claim is at the heart of the proof:
Claim. Let be the numbers of pebbles on the non-empty piles of a terminal configuration . Then there exists a unique such that is even. Moreover, for all we have for all .
Proof of Claim. Since the configuration is good, there must exist such that is even. Moreover, by assumption, if we split the pile with pebbles into two equal halves, the resulting configuration will not be good. By part (ii) of Lemma 2, the only way this can happen is that and for all are odd. To prove the second assertion, we proceed by induction on , with the case already being established. If , then split the pile with pebbles into two equal halves and move one half to the pile with pebbles. Since and are both odd, is even, so by part (ii) of Lemma 2, the resulting configuration is good. Thus, is terminal, so by the induction hypothesis, we have , whence , as desired.
Suppose for contradiction that there exists a configuration as in the Claim. It follows that there exists and an odd integer such that and for all . Thus, is an odd common divisor of , so by the odd divisor property, we must have . But then we can obtain a simple configuration by splitting the only pile with two pebbles into two piles each consisting of a single pebble, which is a contradiction.
With the aid of Lemmas 2 and 3, it is not hard to characterise all solvable configurations:
Lemma 4. A configuration of piles is solvable if and only if it is simple or good.
Proof. () Suppose is not simple. Then since we have to be able to perform at least one move, there must be at least one non-empty pile in with an even number of pebbles. Moreover, by Lemma 2, has the odd divisor property, so it must be good.
() This follows by repeatedly applying Lemma 3 until we reach a simple configuration. Note that the process must stop eventually since the number of non-empty piles is bounded from above.
Finally, the answer to the problem is implied by the following corollary of Lemma 4:
Lemma 5. Let be a positive integer. Then (i) a configuration consisting of a single pile of pebbles is solvable if and only if is a power of two; (ii) if , then the configuration consisting of piles of sizes and is good.
Proof. (i) By Lemma 4, this configuration is solvable if and only if either or is even and has no non-trivial odd divisor, so the conclusion follows.
(ii) Since is even and has no non-trivial odd divisor, this configuration is certainly good, so the conclusion follows by Lemma 4.
Final answer
1 if n is a power of 2; otherwise 2
Techniques
Invariants / monovariantsGames / greedy algorithmsGreatest common divisors (gcd)