Skip to main content
OlympiadHQ

Browse · MathNet

Print

Czech-Slovak-Polish Match

Czech Republic counting and probability

Problem

On the table there are heaps of stones, where . In the first step, we choose any three of the heaps on the table, merge them into a single new heap, and remove 1 stone (throw it away from the table) from this new heap. In the second step, we again merge some three of the heaps together into a single new heap, and then remove 2 stones from this new heap. In general, in the -th step we choose any three of the heaps, which contain more than stones when combined, we merge them into a single new heap, and then remove stones from this new heap. Assume that after a number of steps, there is a single heap left on the table, containing stones. Show that the number is a perfect square if and only if the numbers and are perfect squares. Further, find the least number for which is a perfect square.
Solution
After steps, there will be heaps left on the table; thus if a single heap is to remain in the end, the number must be odd and the total number of steps has to be . Let us distinguish two cases, according as the remainder of upon division by 4 is 1 or 3.

The case of . In the beginning there are stones on the table, from which in course of the steps we will remove stones; thus the number of stones in the last heap will be Since the numbers and are coprime, is a perfect square if and only if both and are perfect squares; that is, if and only if their quadruples and are perfect squares.

The case of . In the beginning there are stones on the table, from which we remove in course of all the steps a total of stones; thus the last single heap will contain If were a perfect square, then so would have to be the two coprime numbers and . Let us show that this is not possible. Assume that there exist natural numbers such that and . From the equality it follows that the number is odd, hence gives a remainder of 1 upon division by 8. The number then gives the remainder of 2, which implies that gives remainder 1 upon division by 4 — a contradiction. Hence in the case of the number is never a perfect square, and likewise the number is never a perfect square (being an even number not divisible by 4).

Let us finally find the least number , , for which both numbers and are perfect squares. From the equalities and for suitable integers it follows that , whence is odd, but then the number gives remainder 2 upon division by 4, so is also odd. Set , ( integer) and substitute this into the equality ; upon a small manipulation this leads to the relation , and taking successively we soon find the smallest solution and , corresponding to and .
Final answer
161

Techniques

Invariants / monovariantsSums and productsGreatest common divisors (gcd)Pell's equationsTechniques: modulo, size analysis, order analysis, inequalities