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 2929. Each time the character encounters another character, the digits of the current energy value are summed, the result is multiplied by 22, and the obtained number becomes the new energy value. What will be the character's energy level after 100100 encounters?

Show solution

Solution. Find the cycle, then count from its start

Let EtE_t be the energy after tt encounters, so E0=29E_0=29. Compute until a value repeats:

29⟶22⟶8⟶16⟶14⟶10⟶2⟶4⟶8.29\longrightarrow22\longrightarrow8\longrightarrow16\longrightarrow14\longrightarrow10\longrightarrow2\longrightarrow4\longrightarrow8.

The same input always has the same successor. Thus, from E2=8E_2=8, the six values 8,16,14,10,2,48,16,14,10,2,4 repeat. Since 100=2+16⋅6+2100=2+16\cdot6+2, we move two positions forward from 88 in the cycle.

E100=14.\boxed{E_{100}=14.}

Problem 2. Three flasks

Three flasks initially contain 1010, 1111, and 1212 drops of potion. In one experiment, contents (a,b,c)(a,b,c) are replaced simultaneously by

(2a−b,  2b−c+1,  2c−a+2).(2a-b,\;2b-c+1,\;2c-a+2).

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) (7,7,25)(7,7,25); (B) (7,7,7)(7,7,7); (C) (9,12,15)(9,12,15);
(D) (9,12,12)(9,12,12); (E) (10,20,40)(10,20,40).

Show solution

Solution. The total counts the experiments

Adding the three new contents gives

(2a−b)+(2b−c+1)+(2c−a+2)=a+b+c+3.(2a-b)+(2b-c+1)+(2c-a+2)=a+b+c+3.

Swapping flasks leaves the total unchanged. After t≥0t\geq0 experiments, the total must therefore be 33+3t33+3t.

  • (B) has total 21<3321<33, so it is impossible.
  • (D) has total 3333, so it would require zero experiments. Swapping alone cannot change (10,11,12)(10,11,12) into (9,12,12)(9,12,12).
  • (E) has total 7070, which is not divisible by 33, so it is impossible.

A necessary condition is not automatically sufficient. For the other two options, exhibit legal experiments:

(10,11,12)⟶(9,11,16)⟶(7,7,25),(10,11,12)\longrightarrow(9,11,16)\longrightarrow(7,7,25),

(11,10,12)⟶(12,9,15).(11,10,12)\longrightarrow(12,9,15).

All the displayed contents are nonnegative, and swapping accounts for the order in the second line.

Impossible: B, D, E.\boxed{\text{Impossible: B, D, E.}}

Problem 3. Viruses and bacteria

One virus infects a colony of 20002000 bacteria. Every second, each virus destroys 77 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 Bt,VtB_t,V_t be the counts after tt complete seconds, as long as bacteria remain. Then

Vt=2Vt−1,Bt=2(Bt−1−7Vt−1).V_t=2V_{t-1},\qquad B_t=2(B_{t-1}-7V_{t-1}).

Dividing the equations shows that the number of bacteria per virus falls by exactly 77 each second:

BtVt=Bt−1Vt−1−7=2000−7t.\frac{B_t}{V_t}=\frac{B_{t-1}}{V_{t-1}}-7=2000-7t.

After 285285 seconds, there are 22852^{285} viruses and 5⋅22855\cdot2^{285} bacteria. The viruses can destroy 7⋅22857\cdot2^{285} bacteria in the next second, so all bacteria disappear then. At every earlier second the ratio is greater than 77 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.

286 seconds.\boxed{286\text{ seconds}.}

Problem 4. Multiplying digit labels

Each bacterium is labelled by a digit from 00 to 99. 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, 88 and 55 are replaced by 44 and 00, while 11 and 33 are replaced by a single 33.

Initially, there are 7777 bacteria, all labelled 55. 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 0,1,2,50,1,2,5: the only pairs from this set with two-digit products are

(5,5)⟶(2,5),(2,5)⟶(1,0).(5,5)\longrightarrow(2,5),\qquad (2,5)\longrightarrow(1,0).

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 7777 operations without a decrease in the population.

The bound is attainable. Use the first move 7676 times. There are then 7676 twos and one five. For operation 7777, multiply that five by one of the twos. The result consists of 7575 twos, one one and one zero, still 7777 bacteria.

Every remaining pair has a one-digit product, so operation 7878 necessarily decreases the population.

77 operations.\boxed{77\text{ operations}.}

Problem 5. Run the recurrence backwards

The sequence satisfies

an+3=an+an+1an+2(n≥1).a_{n+3}=a_n+a_{n+1}a_{n+2}\qquad(n\geq1).

It is given that a9=1a_9=1, a10=3a_{10}=3, and a11=7a_{11}=7. Find the smallest positive index nn such that ana_n is divisible by 2323.

Show solution

Solution. Recover earlier terms modulo 23

The supplied values are at indices 9,10,119,10,11, so searching only forwards would miss earlier answers. The recurrence has a unique inverse:

an=an+3−an+1an+2.a_n=a_{n+3}-a_{n+1}a_{n+2}.

Calculate backwards, reducing modulo 2323 after each operation. The first steps are a8=4a_8=4, a7=−1a_7=-1, a6=5a_6=5, a5=9a_5=9, and a4=−46a_4=-46. To check smaller indices without large numbers, continue modulo 2323:

a3≡5−0⋅9=5,a2≡9−5⋅0=9,a1≡0−9⋅5≡1.a_3\equiv5-0\cdot9=5,\qquad a_2\equiv9-5\cdot0=9,\qquad a_1\equiv0-9\cdot5\equiv1.

In the table, rnr_n is the least nonnegative residue of ana_n modulo 2323.

nn1234567891011
rnr_n195095224137

Thus a4a_4 is divisible by 2323, and none of a1,a2,a3a_1,a_2,a_3 is.

n=4.\boxed{n=4.}

The terms are not required to be positive. In particular, the negative number −46-46 is divisible by 2323.

Problem 6. A row of light bulbs

A robot's screen displays a row of 20252025 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 10131013 such blocks: rr blocks require at least rr off-bulbs and r−1r-1 separating on-bulbs, so 2r−1≤20252r-1\leq2025.

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.

Illustration of the process described in the caption
The alternating configuration has two boundaries for every off-block, including the two ends. Only the boundaries at the ends of a flipped interval can change.

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 10131013 off-blocks and 20262026 boundaries. The all-on row has none, so at least 2026/2=10132026/2=1013 moves are necessary.

1013 steps.\boxed{1013\text{ steps}.}

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 m×nm\times n rectangle of square cells, where m,nm,n 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 mm and nn.

Show solution

Solution. Track the perimeter, not the area

A lower bound. Let PP 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 k≥2k\geq2 active neighbours, adding it removes kk boundary sides and creates 4−k4-k new ones. Therefore

Pnew−Pold=4−2k≤0.P_{\mathrm{new}}-P_{\mathrm{old}}=4-2k\leq0.

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 ss initially active cells, then initially P≤4sP\leq4s. The completely active rectangle has perimeter 2m+2n2m+2n. Hence

4s≥2m+2n,s≥⌈m+n2⌉.4s\geq2m+2n,\qquad s\geq\left\lceil\frac{m+n}{2}\right\rceil.

A construction attaining the bound. By rotating the panel if necessary, assume m≤nm\leq n. Number rows from top to bottom and columns from left to right. Activate the mm diagonal cells (i,i)(i,i), for 1≤i≤m1\leq i\leq m, of the leftmost m×mm\times m square. That square fills: successive diagonals become active, since every cell on the next diagonal has two active neighbours closer to the main diagonal.

Illustration of the process described in the caption
A 5 by 9 panel needs seven initial cells: five on the diagonal and two in the top row. The square fills first; each extra seed allows two more columns to fill.

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 m=1m=1, and their total attains the lower bound:

m+⌈n−m2⌉=⌈m+n2⌉m+\left\lceil\frac{n-m}{2}\right\rceil=\boxed{\left\lceil\frac{m+n}{2}\right\rceil}

Problem 8. A number-sorting machine

For a positive integer nn, a machine stores the following n+1n+1 numbers:

3n,  2⋅3n−1,  22⋅3n−2,  …,  2n.3^n,\;2\cdot3^{n-1},\;2^2\cdot3^{n-2},\;\ldots,\;2^n.

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 nn.

Show solution

Solution. Sort the prime exponents

Why the machine stops. Replacing a,ba,b by their greatest common divisor and least common multiple preserves their product. Thus the product QQ of all n+1n+1 stored numbers is fixed. Every stored number is a positive integer at most QQ, so their sum is bounded above by (n+1)Q(n+1)Q.

Write a=gua=gu, b=gvb=gv, where g=gcd⁡(a,b)g=\gcd(a,b) and gcd⁡(u,v)=1\gcd(u,v)=1. Since neither chosen number divides the other, both uu and vv are greater than 11. The new numbers are gg and guvguv, and the change in their sum is

g+guv−gu−gv=g(u−1)(v−1)>0.g+guv-gu-gv=g(u-1)(v-1)>0.

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 2a3b2^a3^b, where a,ba,b 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 22 is unchanged; the same is true separately for 33. Each remains

{0,1,…,n}.\{0,1,\ldots,n\}.

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 0,1,…,n0,1,\ldots,n, the exponent of each prime in position i+1i+1 is exactly ii.

Thus, regardless of the machine's choices, the final numbers are

1,6,62,…,6n.1,6,6^2,\ldots,6^n.

Their sum is a geometric progression:

1+6+62+⋯+6n=6n+1−15.\boxed{1+6+6^2+\cdots+6^n=\frac{6^{n+1}-1}{5}.}

Problem 9. Operating systems on a network

A computer network has 100100 servers. Some pairs are connected. Each server uses system AA or system BB. 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 AA does not give a direction of progress: either kind of change is possible. Instead, let DD be the number of edges whose endpoints use different systems.

Suppose the changing server has pp neighbours using its own system and qq using the other, where q>pq>p. Its qq disagreeing edges become agreeing; its pp agreeing edges become disagreeing. All other edges are unchanged. Thus

D′=D−q+p<D.D'=D-q+p<D.

The nonnegative integer DD strictly decreases at every change. There can be at most its initial value many changes, and this is at most (1002)=4950\binom{100}{2}=4950.

Every sequence of allowed changes is finite.\boxed{\text{Every sequence of allowed changes is finite.}}

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 x>1x>1. Every second it chooses any prime divisor pp of xx and replaces xx with

y=xp(p−1)k,y=\frac{x}{p}(p-1)^k,

where kk is any positive integer, possibly different at every step. Prove that eventually the stored number becomes 11.

Show solutions · 2 viewpoints

Solution 1. Compare prime exponents from largest to smallest

The number itself can grow dramatically. But every prime divisor of p−1p-1 is smaller than pp. Let PP be the largest prime factor of the initial number. No later number can have a prime factor larger than PP.

List all primes at most PP in decreasing order, q1>q2>⋯>qr=2q_1>q_2>\cdots>q_r=2, and write the current factorisation as x=∏i=1rqieix=\prod_{i=1}^r q_i^{e_i}. Associate to it the fixed-length tuple

(e1,e2,…,er).(e_1,e_2,\ldots,e_r).

If p=qjp=q_j is chosen, the exponents before position jj are unchanged, eje_j 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 11 has a prime divisor and permits another move, so the terminal number is 11.

Every legal process eventually reaches 1.\boxed{\text{Every legal process eventually reaches }1.}

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 pp and replaces it with the finitely many prime-factor tokens of (p−1)k(p-1)^k, all smaller than pp.

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 PP. Each vertex has finitely many children, because the chosen kk 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 11 and a face-up card by 00. Turning a stack over reverses its order and switches every bit. The total number of ones need not decrease.

Illustration of the process described in the caption
A legal move can increase the number of face-down cards. Nevertheless, its first changed bit goes from 1 to 0, so the binary value decreases.

Suppose the selected stack occupies positions i,…,ji,\ldots,j. Positions before ii are unchanged. Its new first card is the old last card turned over. The latter was face down, so the bit at position ii changes from 11 to 00.

For a deck of NN cards, interpret the bit string as the nonnegative integer

F=∑k=1Nbk2N−k.F=\sum_{k=1}^N b_k2^{N-k}.

At position ii, the decrease is 2N−i2^{N-i}. Even if every later bit increased, their total possible increase would be only 2N−i−12^{N-i}-1. Thus FF decreases by at least one at every move.

There are at most F0≤2N−1F_0\leq2^N-1 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.

All cards eventually face up.\boxed{\text{All cards eventually face up.}}

Problem 12. Non-crossing red-blue matching

There are 2n2n points in the plane, nn blue and nn red, with no three collinear. Prove that they can be paired by nn 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 n!n!. Choose one whose sum of segment lengths is smallest.

Suppose two of its segments, R1B1R_1B_1 and R2B2R_2B_2, intersect at XX. Replace them by R1B2R_1B_2 and R2B1R_2B_1. This is still a red-blue pairing.

Illustration of the process described in the caption
Swap the blue endpoints of the crossing pair. The strict triangle inequalities make the total length smaller.

No three original points are collinear, so the relevant triangle inequalities are strict:

∣R1B2∣<∣R1X∣+∣XB2∣,∣R2B1∣<∣R2X∣+∣XB1∣.|R_1B_2|<|R_1X|+|XB_2|,\qquad |R_2B_1|<|R_2X|+|XB_1|.

Adding gives

∣R1B2∣+∣R2B1∣<∣R1B1∣+∣R2B2∣.|R_1B_2|+|R_2B_1|<|R_1B_1|+|R_2B_2|.

This contradicts the minimality of the chosen pairing. Therefore it has no intersecting segments.

A non-crossing red-blue pairing exists.\boxed{\text{A non-crossing red-blue pairing exists.}}

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.