Youth Math Club 26/27 · Problem set
Semi-Invariants
Semi-Invariants · Problem set
Open a solution below each problem.
Problem 1. Energy and digit sums
In a computer game, a character starts with an initial energy level of . Each time the character encounters another character, the digits of the current energy value are summed, the result is multiplied by , and the obtained number becomes the new energy value. What will be the character's energy level after encounters?
Show solution
Solution. Find the cycle, then count from its start
Let be the energy after encounters, so . Compute until a value repeats:
The same input always has the same successor. Thus, from , the six values repeat. Since , we move two positions forward from in the cycle.
Problem 2. Three flasks
Three flasks initially contain , , and drops of potion. In one experiment, contents are replaced simultaneously by
Transferring potion between flasks is not allowed, but swapping flasks is permitted. Select all triples that cannot be obtained; the order of the three numbers does not matter.
(A) ; (B) ; (C) ;
(D) ; (E) .
Show solution
Solution. The total counts the experiments
Adding the three new contents gives
Swapping flasks leaves the total unchanged. After experiments, the total must therefore be .
- (B) has total , so it is impossible.
- (D) has total , so it would require zero experiments. Swapping alone cannot change into .
- (E) has total , which is not divisible by , so it is impossible.
A necessary condition is not automatically sufficient. For the other two options, exhibit legal experiments:
All the displayed contents are nonnegative, and swapping accounts for the order in the second line.
Problem 3. Viruses and bacteria
One virus infects a colony of bacteria. Every second, each virus destroys bacteria and creates a copy of itself, after which each remaining bacterium also creates a copy of itself. How many seconds will it take for the colony to be completely destroyed?
If the viruses can destroy all the remaining bacteria, they do so during that second.
Show solution
Solution. Count bacteria per virus
Both populations double, so their ratio is simpler than their actual sizes. Let be the counts after complete seconds, as long as bacteria remain. Then
Dividing the equations shows that the number of bacteria per virus falls by exactly each second:
After seconds, there are viruses and bacteria. The viruses can destroy bacteria in the next second, so all bacteria disappear then. At every earlier second the ratio is greater than before the attack, so extinction has not yet occurred.
Do not continue the recurrence to a negative population. It applies only while bacteria survive the attack.
Problem 4. Multiplying digit labels
Each bacterium is labelled by a digit from to . In one operation, two bacteria are selected and replaced by bacteria whose labels are the decimal digits of the product of the selected labels. For example, and are replaced by and , while and are replaced by a single .
Initially, there are bacteria, all labelled . What is the maximum number of operations that can be performed without decreasing the number of bacteria?
Show solution
Solution. Count the fives
Before the first decrease, every chosen product must have two digits. Starting from fives, the only possible labels during this stage are : the only pairs from this set with two-digit products are
This also proves by induction that no other label can appear during this stage. Each of these moves reduces the number of fives by exactly one. Therefore there can be at most operations without a decrease in the population.
The bound is attainable. Use the first move times. There are then twos and one five. For operation , multiply that five by one of the twos. The result consists of twos, one one and one zero, still bacteria.
Every remaining pair has a one-digit product, so operation necessarily decreases the population.
Problem 5. Run the recurrence backwards
The sequence satisfies
It is given that , , and . Find the smallest positive index such that is divisible by .
Show solution
Solution. Recover earlier terms modulo 23
The supplied values are at indices , so searching only forwards would miss earlier answers. The recurrence has a unique inverse:
Calculate backwards, reducing modulo after each operation. The first steps are , , , , and . To check smaller indices without large numbers, continue modulo :
In the table, is the least nonnegative residue of modulo .
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | |
| 1 | 9 | 5 | 0 | 9 | 5 | 22 | 4 | 1 | 3 | 7 |
Thus is divisible by , and none of is.
The terms are not required to be positive. In particular, the negative number is divisible by .
Problem 6. A row of light bulbs
A robot's screen displays a row of light bulbs, some on and others off. In one step, the robot can change the state of every bulb in any one nonempty consecutive interval. What is the minimum number of steps that is always sufficient to turn on all the bulbs?
Oral submission. Explain a strategy that works for every initial configuration and prove that fewer steps cannot always suffice.
Show solution
Solution. Count the boundaries of off-blocks
An upper bound. Turn on each maximal consecutive block of off-bulbs in one move. There can be at most such blocks: blocks require at least off-bulbs and separating on-bulbs, so .
Why fewer moves cannot always work. Imagine a permanently on bulb just outside each end of the row. Count adjacent pairs with different states. An off-block contributes two such boundaries.
Flipping an interval leaves every internal comparison unchanged: both bulbs are flipped together. Only its two endpoint comparisons change. Hence a move can remove at most two boundaries.
The alternating row off, on, off, on, ..., off has off-blocks and boundaries. The all-on row has none, so at least moves are necessary.
The argument proves more: for any fixed initial row, the exact minimum is the number of its off-blocks.
Problem 7. Activating a rectangular panel
A control panel consists of an rectangle of square cells, where are positive integers. Initially, you activate some cells of your choice. Every second, each inactive cell sharing a side with at least two active cells becomes active. Active cells remain active.
What is the smallest number of cells you can activate initially so that, with a suitable choice of their positions, the entire panel eventually becomes active? Give your answer as a formula in and .
Show solution
Solution. Track the perimeter, not the area
A lower bound. Let be the perimeter of the union of active unit squares, including boundaries around holes and along the outside of the panel.
If a new cell has active neighbours, adding it removes boundary sides and creates new ones. Therefore
A simultaneous update can be counted one cell at a time: each new cell still has at least two active neighbours, so the perimeter cannot increase.
If there are initially active cells, then initially . The completely active rectangle has perimeter . Hence
A construction attaining the bound. By rotating the panel if necessary, assume . Number rows from top to bottom and columns from left to right. Activate the diagonal cells , for , of the leftmost square. That square fills: successive diagonals become active, since every cell on the next diagonal has two active neighbours closer to the main diagonal.
Pair the remaining columns from left to right. In each pair, activate the top cell of the right-hand column. Once the rectangle to its left is active, the pair's top-left cell activates, having active neighbours on both sides. The left-hand column then fills downwards, each cell using its left and upper neighbours. The right-hand column follows in the same way.
For an unpaired final column, activate its top cell; it fills downwards using its active left neighbour. All seeds are chosen initially. This also works for , and their total attains the lower bound:
Problem 8. A number-sorting machine
For a positive integer , a machine stores the following numbers:
In one operation, it chooses two stored numbers such that neither divides the other and replaces them with their greatest common divisor and least common multiple. The machine continues until no operation is possible.
What is the sum of the numbers then? Give your answer as a formula in .
Show solution
Solution. Sort the prime exponents
Why the machine stops. Replacing by their greatest common divisor and least common multiple preserves their product. Thus the product of all stored numbers is fixed. Every stored number is a positive integer at most , so their sum is bounded above by .
Write , , where and . Since neither chosen number divides the other, both and are greater than . The new numbers are and , and the change in their sum is
The sum is therefore a strictly increasing bounded integer. Only finitely many operations are possible.
What remains. Every number throughout the process has the form , where are nonnegative integers. For two such numbers, their greatest common divisor takes the smaller exponent of each prime, and their least common multiple takes the larger exponent. Consequently, the multiset of exponents of is unchanged; the same is true separately for . Each remains
At the end, every pair of numbers is comparable by divisibility. Arrange the numbers in increasing order. Each then divides the next, so both lists of prime exponents must be nondecreasing. Since each list is a permutation of , the exponent of each prime in position is exactly .
Thus, regardless of the machine's choices, the final numbers are
Their sum is a geometric progression:
Problem 9. Operating systems on a network
A computer network has servers. Some pairs are connected. Each server uses system or system . Each year, one server may change its system if a strict majority of its neighbours use the other system. Prove that the process of system changes cannot continue indefinitely.
Show solution
Solution. Count disagreeing connections
Counting servers with system does not give a direction of progress: either kind of change is possible. Instead, let be the number of edges whose endpoints use different systems.
Suppose the changing server has neighbours using its own system and using the other, where . Its disagreeing edges become agreeing; its agreeing edges become disagreeing. All other edges are unchanged. Thus
The nonnegative integer strictly decreases at every change. There can be at most its initial value many changes, and this is at most .
The rule changes one server at a time and requires a strict majority. These conditions are used in the proof. The conclusion concerns the number of changes, not years in which nothing happens.
Problem 10. Prime factors that split
A supercomputer stores a positive integer . Every second it chooses any prime divisor of and replaces with
where is any positive integer, possibly different at every step. Prove that eventually the stored number becomes .
Show solutions · 2 viewpoints
Solution 1. Compare prime exponents from largest to smallest
The number itself can grow dramatically. But every prime divisor of is smaller than . Let be the largest prime factor of the initial number. No later number can have a prime factor larger than .
List all primes at most in decreasing order, , and write the current factorisation as . Associate to it the fixed-length tuple
If is chosen, the exponents before position are unchanged, decreases by one, and only later exponents may increase. The tuple therefore strictly decreases in lexicographic order.
A fixed-length tuple of nonnegative integers cannot decrease lexicographically forever. The first coordinate can drop only finitely often, then stays fixed; the same argument applies successively to every remaining coordinate. Thus the process stops. Any integer greater than has a prime divisor and permits another move, so the terminal number is .
Solution 2. A finite genealogy of factors
Think of each prime factor, with multiplicity, as a token labelled by that prime. A move removes one token and replaces it with the finitely many prime-factor tokens of , all smaller than .
Record these replacements as a family tree for each initial token. Along a branch, prime labels strictly decrease, so its depth is bounded by the number of primes at most . Each vertex has finitely many children, because the chosen is finite. A tree of bounded depth with finite branching has finitely many vertices, by induction on its depth. There are finitely many initial tokens, so only finitely many replacements can occur.
Problem 11. Turning over a stack of cards
Some cards in a finite deck are face down. Alex repeatedly selects one or more consecutive cards such that both the top and bottom cards of the selected stack are face down. He turns the entire stack over as a whole and puts it back in the same position. A one-card stack is allowed only when that card is face down.
Prove that eventually all cards are face up, regardless of the choices of moves.
Show solution
Solution. Give earlier cards greater weight
Read the deck from top to bottom. Encode a face-down card by and a face-up card by . Turning a stack over reverses its order and switches every bit. The total number of ones need not decrease.
Suppose the selected stack occupies positions . Positions before are unchanged. Its new first card is the old last card turned over. The latter was face down, so the bit at position changes from to .
For a deck of cards, interpret the bit string as the nonnegative integer
At position , the decrease is . Even if every later bit increased, their total possible increase would be only . Thus decreases by at least one at every move.
There are at most moves. If any face-down card remained, turning that one card over would still be legal. Hence a process that continues whenever possible must finish with every card face up.
Problem 12. Non-crossing red-blue matching
There are points in the plane, blue and red, with no three collinear. Prove that they can be paired by segments, each joining a red point to a blue point, so that no two segments intersect.
Show solution
Solution. Uncross a shortest matching
There are only finitely many red-blue pairings, in fact . Choose one whose sum of segment lengths is smallest.
Suppose two of its segments, and , intersect at . Replace them by and . This is still a red-blue pairing.
No three original points are collinear, so the relevant triangle inequalities are strict:
Adding gives
This contradicts the minimality of the chosen pairing. Therefore it has no intersecting segments.
An equivalent algorithm repeatedly uncrosses any crossing pair. Total length strictly decreases, and there are only finitely many pairings, so the algorithm terminates. A decreasing positive real quantity alone would not prove termination; the finiteness of the state space is essential here.