Library · Between the Challenge and the Olympiad · Chapter 10

Pigeonhole, Extremal and Invariants

Revised Report an error
On this page
  1. Problems
  2. Solutions
  3. Solution: IOQM 2021 Part A, Q2
  4. Solution: PRMO 2015 Part A, Q17
  5. Solution: IOQM 2020, Q10
  6. Solution: IOQM 2024, Q20
  7. Solution: IOQM 2025 Part SEP, Q28
  8. Solution: PRMO 2013, Q13
  9. Solution: IOQM 2021 Part A, Q12
  10. Solution: IOQM 2023, Q27
  11. Solution: IOQM 2023, Q28
  12. Solution: IOQM 2025 Part SEP, Q7

Problems

Problem 1

Rosie writes down the numbers 1,2,…,1011, 2, \ldots, 101 in red and blue pens. The largest blue number is equal to the number of numbers written in blue and the smallest red number is equal to half the number of numbers written in red. How many numbers did Rosie write with red pen?

Problem 2

A subset BB of the set of first 100 positive integers has the property that no two elements of BB sum to 125. What is the maximum possible number of elements in BB?

Problem 3

Five students take a test on which any integer score from 00 to 100100 inclusive is possible. What is the largest possible difference between the median and the mean of the scores? (The median of a set of scores is the middlemost score when the data is arranged in increasing order. It is exactly the middle score when there are an odd number of scores and it is the average of the two middle scores when there are an even number of scores.)

Problem 4

On a natural number nn you are allowed two operations: (1)(1) multiply nn by 22 or (2)(2) subtract 33 from nn. For example starting with 88 you can reach 1313 as follows: 8→16→138 \to 16 \to 13. You need two steps and you cannot do in less than two steps. Starting from 1111, what is the least number of steps required to reach 121121?

Problem 5

There are 100 cards in a box which are numbered from 1 to 100. While being blindfolded, Michael is going to draw one or more cards from the box. After that, he will remove his blindfold and multiply together the numbers on these cards. Michael wants the product of the numbers on the cards drawn to be a multiple of 6. How many cards does he need to draw to make sure that this will happen?

Problem 6

To each element of the set S={1,2,…,1000}S = \{1, 2, \ldots , 1000\} a colour is assigned. Suppose that for any two elements a,ba, b of SS, if 15 divides a+ba + b then they are both assigned the same colour. What is the maximum possible number of distinct colours used?

Problem 7

A 12×1212 \times 12 board is divided into 144 unit squares by drawing lines parallel to the sides. Two rooks placed on two unit squares are said to be non attacking if they are not in the same column or same row. Find the least number NN such that if NN rooks are placed on the unit squares, one rook per square, we can always find 7 rooks such that no two are attacking each other.

Problem 8

A quadruple (a,b,c,d)(a, b, c, d) of distinct integers is said to be balanced if a+c=b+da + c = b + d. Let S\mathcal{S} be any set of quadruples (a,b,c,d)(a, b, c, d) where 1≤a<b<d<c≤201 \leq a < b < d < c \leq 20 and where the cardinality of S\mathcal{S} is 4411. Find the least number of balanced quadruples in S\mathcal{S}.

Problem 9

On each side of an equilateral triangle with side length nn units, where nn is an integer, 1≤n≤1001 \leq n \leq 100, consider n−1n - 1 points that divide the side into nn equal segments. Through these points, draw lines parallel to the sides of the triangle, obtaining a net of equilateral triangles of side length one unit. On each of the vertices of these small triangles, place a coin head up. Two coins are said to be adjacent if the distance between them is 1 unit. A move consists of flipping over any three mutually adjacent coins. Find the number of values of nn for which it is possible to turn all coins tail up after a finite number of moves.

n = 4 , one move shaded
n=4n = 4, one move shaded

Problem 10

There are mm blue marbles and nn red marbles on a table. Alex and Bella play a game by taking turns. In each turn the player has to pick a marble of the colour of their choice. Alex starts first, and the player who picks the last red marble wins. For how many choices of (m,n)(m, n) with 1≤m,n≤111 \leq m, n \leq 11 can Alex force a win?

Problem 11

A regular polygon with n≥5n \geq 5 vertices is said to be colourful if it is possible to colour the vertices using at most 6 colours such that each vertex is coloured with exactly one colour, and such that any 5 consecutive vertices have different colours. Find the largest number nn for which a regular polygon with nn vertices is not colourful.

Problem 12

The vertices of a regular dodecagon (a polygon with 12 sides) are coloured either blue or red. Let NN be the number of all possible colourings such that no three points of the same colour form the vertices of an equilateral triangle, and no four points of the same colour form the vertices of a square. If NN can be written as N=100p+qN = 100p + q where p,qp, q are two positive integers less than 100, find p+qp + q.

one of the four triangles, one of the three squares
one of the four triangles, one of the three squares

Solutions

Solution: IOQM 2021 Part A, Q2

Key idea

Saying that the largest blue number equals how many blue numbers there are leaves no freedom at all: the blue numbers must be exactly 11 through bb.

Let bb be the number of blue entries and rr the number of red ones, so b+r=101b + r = 101.

Read the first condition carefully. The largest blue number is bb, so every blue number is at most bb, and there are bb of them. But there are only bb numbers in the whole list that are at most bb, namely 1,2,…,b1, 2, \ldots, b, so the blue numbers are precisely those and nothing is left over. That single observation removes all the freedom from the problem.

Everything else is therefore red, so the red numbers are b+1,b+2,…,101b+1, b+2, \ldots, 101 and the smallest red number is b+1b + 1. The second condition says this equals half the number of reds: b+1=r2=101−b2.b + 1 = \frac{r}{2} = \frac{101 - b}{2}. Clearing the denominator gives 2b+2=101−b2b + 2 = 101 - b, so 3b=993b = 99 and b=33b = 33.

Hence r=101−33=68r = 101 - 33 = 68, and as a check the smallest red number is 3434, which is indeed half of 6868.

Answer 68

Solution: PRMO 2015 Part A, Q17

Key idea

Pair up the numbers that sum to 125125; from each pair at most one may be chosen, and every number outside the pairs is free.

The pairs {m,125−m}\{m, 125-m\} with both entries in {1,2,…,100}\{1, 2, \ldots, 100\} need 125−m≤100125 - m \le 100, that is m≥25m \ge 25. So the pairs are {25,100}, {26,99}, …, {62,63},\{25, 100\},\ \{26, 99\},\ \ldots,\ \{62, 63\}, of which there are 62−25+1=3862 - 25 + 1 = 38. Together they use up the numbers 2525 through 100100, and the remaining numbers 11 through 2424 belong to no pair at all, because for those mm the partner 125−m125 - m exceeds 100100.

Now the two halves of the argument. Any admissible BB contains at most one member of each pair, so ∣B∣≤24+38=62|B| \le 24 + 38 = 62. And 6262 is attained: take all of 11 through 2424 together with the larger member of each pair, that is 6363 through 100100. No two of the chosen numbers sum to 125125, since two numbers below 2525 sum to at most 4848, two numbers above 6262 sum to at least 127127, and a number below 2525 paired with one above 6262 sums to at most 24+100=12424 + 100 = 124.

Hence the maximum is 6262.

Answer 62

Solution: IOQM 2020, Q10

Key idea

Writing the difference as one fraction makes the median partly cancel, and what is left is pushed to its extreme by sending each remaining score to an endpoint of its permitted range.

Order the five scores as a≤b≤c≤d≤ea \leq b \leq c \leq d \leq e, so that the median is the middle one, cc. Rather than reasoning about the median and the mean separately, it pays to write their difference as a single fraction and see which letters actually survive: c−mean=c−a+b+c+d+e5=4c−a−b−d−e5.c - \text{mean} = c - \frac{a+b+c+d+e}{5} = \frac{4c - a - b - d - e}{5}.

The expression is increasing in cc and decreasing in each of aa, bb, dd and ee, so we would like cc large and the other four small. The ordering constraint is what stops us: dd and ee are not allowed to fall below cc. The best available compromise is therefore to send aa and bb down to 00, hold dd and ee at their lowest permitted value cc, and then read off 4c−0−0−c−c5=2c5,\frac{4c - 0 - 0 - c - c}{5} = \frac{2c}{5}, which is largest when cc takes its maximum value 100100, giving a difference of 4040.

It is worth checking the opposite direction, since the question asks only for the largest difference and does not say which way round it runs. There mean−c=a+b+d+e−4c5,\text{mean} - c = \frac{a + b + d + e - 4c}{5}, and now aa and bb are at most cc while dd and ee are at most 100100, so a+b+d+e−4c≤2c+200−4c=200−2c≤200a + b + d + e - 4c \le 2c + 200 - 4c = 200 - 2c \le 200. Taking a=b=c=0a = b = c = 0 with d=e=100d = e = 100 reaches 200/5=40200/5 = 40 once again. The two extremes happen to agree, so the answer is 4040 whichever way the gap opens.

Answer 40

Solution: IOQM 2024, Q20

Key idea

Track what the doublings do: after dd of them the reachable numbers are 11⋅2d−3S11 \cdot 2^d - 3S, where SS is a sum of one power of two per subtraction, so the question becomes how few powers of two can add up to the required SS.

Suppose the journey uses dd doublings and ss subtractions. Follow a single subtraction: if it is performed when jj doublings still lie ahead, then by the end it has reduced the final value by 3⋅2j3 \cdot 2^j, because each later doubling doubles whatever was taken away along with everything else. Try it on a short journey. Starting from 1111, subtracting 33 and then doubling twice gives 11→8→16→3211 \to 8 \to 16 \to 32, whereas doubling twice alone gives 4444; the 33 removed at the start has cost 3⋅22=123 \cdot 2^2 = 12 by the end. Hence 121=11⋅2d−3S,S=∑i=1s2ji,0≤ji≤d.121 = 11 \cdot 2^d - 3S, \qquad S = \sum_{i=1}^{s} 2^{j_i}, \quad 0 \le j_i \le d.

Now narrow dd down. Doublings are the only way to grow, and 11⋅23=88<12111 \cdot 2^3 = 88 < 121, so d≥4d \ge 4.

First, dd must be odd. Working modulo 33, where 2≡−12 \equiv -1, 11⋅2d−121≡2⋅(−1)d−1(mod3),11 \cdot 2^d - 121 \equiv 2 \cdot (-1)^d - 1 \pmod 3, which is 11 for even dd and 00 for odd dd. Only the odd values leave 3S3S a whole multiple of 33, so d=4d = 4 and d=6d = 6 are out, along with every other even value.

d=5d = 5

Here 11⋅32−121=23111 \cdot 32 - 121 = 231, so S=77S = 77 with every term at most 25=322^5 = 32. Since 7777 is odd and 11 is the only odd power of two, an odd number of the terms equal 11. Three or more of them already mean six terms in all, since three ones leave 7474, and two terms of at most 3232 make at most 6464, so at least three more are needed. So take the case of exactly one 11, where the rest total 7676. Two terms give at most 6464. Three cannot reach 7676 either: one of them must be 3232, because three terms of 1616 or less total at most 4848, and the remaining pair would then have to make 4444, which no two powers of two at most 3232 do. So s≥5s \ge 5, and s=5s = 5 is achieved by 77=32+32+8+4+177 = 32+32+8+4+1, giving d+s=10d + s = 10.

d≥7d \ge 7

Here SS is large compared with the biggest term available. From S=(11⋅2d−121)/3S = \left(11 \cdot 2^d - 121\right)/3, S>3⋅2dS > 3 \cdot 2^d exactly when 11⋅2d−121>9⋅2d11 \cdot 2^d - 121 > 9 \cdot 2^d, that is when 2d+1>1212^{d+1} > 121, which holds for every d≥6d \ge 6. Since each term is at most 2d2^d, three terms could never reach SS, so s≥4s \ge 4 and d+s≥7+4=11,d + s \ge 7 + 4 = 11, worse than 1010.

So the least total is d+s=5+5=10d + s = 5 + 5 = 10, and here is a route that achieves it: 11→8→5→10→20→17→34→31→62→124→121.11 \to 8 \to 5 \to 10 \to 20 \to 17 \to 34 \to 31 \to 62 \to 124 \to 121. Notice that it begins by going down, which is the step most people do not try. Subtracting early is cheap precisely because a later doubling magnifies whatever has been taken off.

Answer 10

Solution: IOQM 2025 Part SEP, Q28

Key idea

Sixty-seven of the cards are not multiples of three, against only fifty odd ones, so the multiples of three are the binding constraint.

The product is a multiple of 66 exactly when the cards drawn include at least one even number and at least one multiple of 33.

So consider what can go wrong. A draw avoiding every even number can be as large as the number of odd cards, which is 5050. A draw avoiding every multiple of 33 can be as large as 100−⌊100/3⌋=100−33=67100 - \lfloor 100/3 \rfloor = 100 - 33 = 67. The second is the binding constraint, so drawing 6767 cards is not enough: the 6767 non-multiples of 33 are a genuine bad draw.

With 6868 cards both risks vanish. Only 6767 cards are not multiples of 33, so any 6868 must include one; and only 5050 cards are odd, so any 6868 must include an even one.

Hence 6868 cards are needed, and they suffice.

Answer 68

Solution: PRMO 2013, Q13

Key idea

The rule ties remainder rr to remainder 15−r15 - r, and going round through the partner class ties each remainder class together, leaving eight groups.

Work modulo 1515. The rule says that if a+b≡0a + b \equiv 0 then aa and bb share a colour.

First, the remainder 00: any two multiples of 1515 sum to a multiple of 1515, so all of them share one colour.

Next, take rr between 11 and 1414. Every element of remainder rr must share a colour with every element of remainder 15−r15-r, and both classes are non-empty, since 10001000 is far more than 1515. Two elements aa and a′a' of the same remainder rr are therefore forced together as well, through any element of remainder 15−r15 - r. So each pair of classes {r,15−r}\{r, 15-r\} is a single colour.

That gives the groups {0}, {1,14}, {2,13}, {3,12}, {4,11}, {5,10}, {6,9}, {7,8},\{0\}, \ \{1,14\}, \ \{2,13\}, \ \{3,12\}, \ \{4,11\}, \ \{5,10\}, \ \{6,9\}, \ \{7,8\}, eight of them, and nothing forces two different groups to share a colour: colouring by group satisfies the rule, since a+b≡0a + b \equiv 0 puts aa and bb in the same group by construction.

So the maximum number of colours is 88.

Note that 1515 being odd is what makes every non-zero class pair with a different one. For an even modulus the class r=m/2r = m/2 would pair with itself and behave like the zero class.

Answer 8

Solution: IOQM 2021 Part A, Q12

Key idea

A placement whose largest non-attacking set has tt rooks can be covered by tt whole rows or columns. That cover bounds the number of rooks, while full rows supply a placement that reaches the bound.

seventy-two rooks in six rows; seven that avoid each other would need seven
seventy-two rooks in six rows;
seven that avoid each other would need seven

The question has two halves, and they need separate arguments: show that 7272 rooks can fail, and show that 7373 rooks never can.

For the first half, notice that mutually non-attacking rooks occupy distinct rows. So if every rook is confined to just six of the twelve rows, no seven of them can ever be pairwise non-attacking, because two of any seven would share a row. Six rows contain 6×12=726 \times 12 = 72

unit squares, and filling all of them gives 7272 rooks with no seven mutually non-attacking. So NN must be at least 7373.

For the second half we need one fact, and it is not a school result, so here it is with a proof. It says that whenever the biggest non-attacking set is small, the rooks themselves must be crowded into a few lines, which is exactly the leverage we want.

The covering lemma

If the largest set of mutually non-attacking rooks has tt members, then every rook on the board can be covered by tt lines, each line a whole row or a whole column.

Fix a largest such set MM, with tt rooks. Call a row or column used if it contains a rook of MM; each rook of MM uses one row and one column, and all of these are distinct.

Now mark some rows and columns as reached. Every unused row is reached to begin with. From a reached row, follow any rook standing in it to that rook’s column and mark that column reached. From a reached column, follow the rook of MM in it, if there is one, back to that rook’s row and mark that row reached. Repeat until nothing new gets marked.

An alternating trail would enlarge the non-attacking set from one rook to two.
An alternating trail would enlarge the non-attacking set from one rook to two.

Every reached column is used. If some reached column were unused, the trail that reached it would run from an unused row to an unused column, alternating between rooks outside MM and rooks inside it. Exchanging along that trail, taking the outside rooks into MM and the inside ones out, would leave a set of mutually non-attacking rooks with one more member than MM, which is impossible.

Take as the cover the reached columns together with the used rows that were not reached. This covers every rook: a rook standing in a reached row has its own column reached, by the marking rule, while a rook in a row that was not reached must be in a used row, since every unused row is reached at the start.

And the cover uses exactly tt lines. Each reached column is used, so it carries a rook of MM, and each unreached row is used as well, since the unused rows are all reached at the start, so it too carries a rook of MM. Every rook of MM is picked up by one of those lines and by only one. By one, because a rook standing in a reached row has its column reached, by the marking rule, so a rook whose column is unreached has its row unreached and is caught by its row. By only one, because a reached column marks its own rook’s row, so a rook whose column is reached has its row reached and is not caught again. Distinct rooks of MM stand in distinct rows and distinct columns, so they are caught by distinct lines, and every line of the cover catches one. The cover and the rooks of MM are therefore in one-to-one correspondence, and that is tt lines.

Stated about rows and columns of a rectangular array rather than a chessboard, that lemma is König’s theorem.

Finishing

Suppose 7373 rooks are placed and the largest mutually non-attacking set had only six members. The lemma would cover all 7373 rooks with six lines. But six lines of a 12×1212 \times 12 board cover 6×12=726 \times 12 = 72 squares at most, holding at most 7272 rooks, one to a square. So seven mutually non-attacking rooks must exist.

Hence N=73N = 73.

Answer 73

Solution: IOQM 2023, Q27

Key idea

The ordering a<b<d<ca < b < d < c makes each four-element subset of {1,…,20}\{1, \ldots, 20\} give exactly one quadruple, and balanced ones correspond to two pairs with the same sum, so the worst case is 44114411 minus the number of unbalanced quadruples.

Read the ordering carefully, because it is not the obvious one: the condition is a<b<d<ca < b < d < c. Given any four-element subset {w<x<y<z}\{w < x < y < z\} of {1,…,20}\{1, \ldots, 20\}, there is exactly one way to name its elements so that this holds, namely a=wa = w, b=xb = x, d=yd = y, c=zc = z. So the quadruples correspond exactly to four-element subsets, and there are (204)=4845\binom{20}{4} = 4845 of them. (Had the ordering been a<b<c<da<b<c<d, the balanced condition a+c=b+da + c = b + d would have been impossible, since then a<ba < b and c<dc < d.)

Such a quadruple is balanced when a+c=b+da + c = b + d, that is w+z=x+yw + z = x + y. So a balanced quadruple is a pair of disjoint pairs with the same sum, and conversely two distinct pairs with the same sum are automatically disjoint and automatically nest, the wider one giving ww and zz. Counting them by the common sum ss, if ksk_s pairs {p<q}\{p < q\} from {1,…,20}\{1,\ldots,20\} have p+q=sp + q = s, the number of balanced quadruples is ∑s(ks2)\sum_s \binom{k_s}{2}.

There is a formula: a pair {p<q}\{p < q\} from {1,…,20}\{1, \ldots, 20\} with p+q=sp + q = s is fixed by its smaller member, which may be anything from max⁡(1,s−20)\max(1, s-20) up to ⌈s/2⌉−1\lceil s/2 \rceil - 1, so ks=⌊s−12⌋  (s≤21),ks=⌊41−s2⌋  (s≥21).k_s = \left\lfloor \frac{s-1}{2} \right\rfloor \ \ (s \le 21), \qquad k_s = \left\lfloor \frac{41-s}{2} \right\rfloor \ \ (s \ge 21). Written out, for s=3,4,…,21s = 3, 4, \ldots, 21 they are 1,1,2,2,3,3,…,9,9,101,1,2,2,3,3,\ldots,9,9,10, and for s=22,…,39s = 22, \ldots, 39 they repeat in reverse, 9,9,8,8,…,1,19,9,8,8,\ldots,1,1, by the symmetry p↦21−pp \mapsto 21-p. Hence ∑s(ks2)=2(0+1+3+6+10+15+21+28+36)+45⏟s≤21\sum_s \binom{k_s}{2} = \underbrace{2\bigl(0+1+3+6+10+15+21+28+36\bigr) + 45}_{s \le 21} +  2(36+28+21+15+10+6+3+1)⏟s≥22,\qquad\qquad + \; \underbrace{2\bigl(36+28+21+15+10+6+3+1\bigr)}_{s \ge 22}, which is 285+240=525285 + 240 = 525.

So 4845−525=43204845 - 525 = 4320 quadruples are unbalanced. A set S\mathcal S of size 44114411 can contain at most all of them, and the remaining 4411−4320=914411 - 4320 = 91 members must be balanced. That many is also achieved, by taking every unbalanced quadruple together with any 9191 balanced ones. The least possible number of balanced quadruples is therefore 4411−4320=91.4411 - 4320 = 91.

Answer 91

Solution: IOQM 2023, Q28

Key idea

Colour the vertices in three classes so that every unit triangle contains exactly one vertex of each class; then every move flips exactly one coin in each class, so the three class sizes must have the same parity, and they do not when 33 divides nn.

the label is (y-x) \bmod 3 ; the rhombus turns over only the ringed pair
the label is (y−x) mod 3(y-x) \bmod 3;
the rhombus turns over only the ringed pair

Start with two small nets. For n=1n=1, the one triangle move flips all three coins. For n=2n=2, performing all four unit-triangle moves flips each corner once and each side-midpoint three times, so again every coin turns over. Yet n=3n=3 will fail: a three-colouring splits its ten coins into classes of sizes 4,3,34,3,3, and every move flips one coin of each class. These examples suggest looking at the colour classes rather than individual coins. Describe a vertex of the net by the triple (x,y,z)(x, y, z) of non-negative integers with x+y+z=nx + y + z = n, the three coordinates being the distances to the three sides in lattice steps. The vertices of an upward unit triangle are (x+1,y,z),(x,y+1,z),(x,y,z+1),x+y+z=n−1,(x+1, y, z), \quad (x, y+1, z), \quad (x, y, z+1), \qquad x+y+z = n-1, and those of a downward one are obtained similarly.

The colouring

Put a vertex in class CrC_r when y−x≡r(mod3)y - x \equiv r \pmod 3. Reading off the three vertices of the upward triangle above, their values of y−xy - x are (y−x)−1,(y−x)+1,(y−x),(y - x) - 1, \qquad (y-x)+1, \qquad (y-x), which are three consecutive remainders, so they are one of each class. The same holds for a downward triangle. Therefore every move flips exactly one coin in each of the three classes.

The obstruction

Suppose all coins can be turned over in kk moves. Within class CrC_r, the total number of flips is exactly kk, since each move contributes one. On the other hand every one of the ∣Cr∣|C_r| coins in that class must be flipped an odd number of times, so the total number of flips in CrC_r has the same parity as ∣Cr∣|C_r|. Hence k≡∣C0∣≡∣C1∣≡∣C2∣(mod2).k \equiv |C_0| \equiv |C_1| \equiv |C_2| \pmod 2.

Counting the classes

Fix zz and let s=n−zs = n - z, so the row consists of the s+1s+1 vertices with xx running from 00 to ss and y=s−xy = s - x. Along the row, y−x=s−2xy - x = s - 2x takes the values s,s−2,s−4,…s, s-2, s-4, \ldots, which modulo 33 cycle through all three remainders in order. So a row of length divisible by 33 contributes equally to the three classes; a row with s≡0(mod3)s \equiv 0 \pmod 3, whose length is s+1≡1s+1 \equiv 1, contributes one extra to C0C_0; and a row with s≡1(mod3)s \equiv 1 \pmod 3 contributes one extra to each of C1C_1 and C2C_2.

Now suppose 3∣n3 \mid n. As zz runs from 00 to nn, the value s=n−zs = n-z runs over 0,1,…,n0, 1, \ldots, n, and among these there are n3+1\tfrac n3 + 1 multiples of 33 but only n3\tfrac n3 values congruent to 11. Hence ∣C0∣=∣C1∣+1=∣C2∣+1,|C_0| = |C_1| + 1 = |C_2| + 1, the parities disagree, and turning every coin over is impossible.

If 3∤n3 \nmid n the three classes have equal size, because rotating the triangle through 120∘120^{\circ}, which sends (x,y,z)(x,y,z) to (z,x,y)(z,x,y), changes y−xy-x by −n-n modulo 33 and therefore permutes the three classes cyclically.

When it can be done

Take two unit triangles sharing an edge. Performing both moves flips the two shared coins twice, so the net effect is to flip just the two opposite coins of the rhombus. Reading off coordinates, those two differ by one of (1,1,−2),(1,−2,1),(−2,1,1),(1, 1, -2), \qquad (1, -2, 1), \qquad (-2, 1, 1), and each of these leaves y−xy - x unchanged modulo 33, so a rhombus move flips two coins of the same class and nothing else.

Next, the rhombus moves reach every vertex of a class from every other. Take any vertex with z≥2z \ge 2: the move (1,1,−2)(1,1,-2) is available, since the rhombus it uses has its other two corners at (x+1,y,z−1)(x+1, y, z-1) and (x,y+1,z−1)(x, y+1, z-1), both inside the triangle. Repeating it brings zz down to 00 or 11. From z=1z = 1, if x≥2x \ge 2 apply (−2,1,1)(-2,1,1) and then (1,1,−2)(1,1,-2), which takes zz from 11 up to 22 and back down to 00; if instead y≥2y \ge 2 use (1,−2,1)(1,-2,1) followed by (1,1,−2)(1,1,-2). One of the two is available unless xx and yy are both at most 11, which forces n≤3n \le 3, and those cases are small enough to see directly. So every vertex is joined to one on the side z=0z = 0.

Along that side the vertices are (x,n−x,0)(x, n-x, 0). A rhombus joins its two opposite corners either way round, so each move may be read as +d+d or as −d-d. Applying (1,−2,1)(1,-2,1) and then (−2,1,1)(-2,1,1) backwards therefore steps by (1,−2,1)+(2,−1,−1)=(3,−3,0),(1,-2,1) + (2,-1,-1) = (3, -3, 0), which lands back on the side and moves xx along in threes. Two vertices of the side lie in the same class exactly when their values of xx agree modulo 33, so those steps join all of them. Each class is therefore connected.

The rest is a standard fact about a connected collection: since each rhombus move flips two of its coins, any pair of coins in one class can be flipped and nothing else, by running along a chain of moves from one to the other and letting the intermediate flips cancel in pairs. So exactly the even-sized subsets of a class can be flipped on their own.

Now finish. When 3∤n3 \nmid n the three classes have the same size mm. If mm is even, flip each class entirely, taking the coins in pairs. If mm is odd, first make one triangle move, which flips one coin in each class and leaves an even number still to flip in each, then finish as before. Either way every coin ends tail up. For instance n=1n = 1 needs one move and n=2n = 2 needs all four unit triangles.

So the flipping is possible exactly when nn is not a multiple of 33. Among 1≤n≤1001 \le n \le 100 there are 3333 multiples of 33, leaving 100−33=67100 - 33 = 67 values of nn.

Answer 67

Solution: IOQM 2025 Part SEP, Q7

Key idea

Except when only one red remains, the position is a win exactly when m+nm+n is odd, because the winner can always hand back a position with m+nm+n even and at least two reds left.

Call a position (m,n)(m,n) with n≥1n \ge 1 reds remaining a win if the player about to move can force a victory. Two facts settle everything.

If n=1n = 1 the mover takes the last red and wins, so every position with one red is a win.

With two reds and no blues, the mover must leave one red to the opponent and loses. With two reds and one blue, taking the blue hands back that losing position. With three reds and no blues, taking one red also hands back the losing two-red position. The total parity has begun to separate these examples, while the one-red case remains exceptional. Now suppose n≥2n \ge 2. We claim the position is a win exactly when m+nm + n is odd, and we check both directions at once by induction on m+nm+n. Note that mm may be 00, in which case the only legal move is to take a red; the argument below covers that case, since the blue move is used only to establish a win, never to rule one out.

Suppose m+nm+n is odd, with n≥2n \ge 2. If n≥3n \ge 3, take a red: the new position is (m,n−1)(m, n-1) with n−1≥2n - 1 \ge 2 and m+n−1m + n - 1 even, which by induction is a loss for the opponent. If n=2n = 2, then mm is odd, so m≥1m \ge 1; take a blue instead, reaching (m−1,2)(m-1, 2) with m−1+2m - 1 + 2 even and two reds still on the table, again a loss for the opponent. Either way the mover wins.

Suppose instead m+nm+n is even, with n≥2n \ge 2. Taking a blue reaches (m−1,n)(m-1, n), where n≥2n \ge 2 and the total is odd, a win for the opponent. Taking a red reaches (m,n−1)(m, n-1): if n−1≥2n - 1 \ge 2 the total is again odd and the opponent wins, and if n−1=1n-1 = 1 the opponent takes the last red and wins. So every move loses.

Count the pairs with 1≤m,n≤111 \le m, n \le 11 that Alex wins:

  • n=1n = 1: all 1111 values of mm.

  • nn even, so n∈{2,4,6,8,10}n \in \{2,4,6,8,10\}: need mm odd, which is 66 values, giving 5⋅6=305 \cdot 6 = 30.

  • nn odd and at least 33, so n∈{3,5,7,9,11}n \in \{3,5,7,9,11\}: need mm even, which is 55 values, giving 2525.

The total is 11+30+25=6611 + 30 + 25 = 66.

Answer 66

Solution: IOQM 2025 Part SEP, Q7

Key idea

Two vertices of the same colour must be at least five apart around the polygon, so each colour is used at most ⌊n/5⌋\lfloor n/5 \rfloor times; with six colours that caps nn, and blocks of five and six vertices build every colouring that is possible.

The condition is that any two vertices within four steps of each other, going around the polygon, receive different colours.

Why n=19n = 19 fails. Fix a colour and look at the vertices carrying it. Any two of them are at least 55 apart around the cycle, so if a colour is used kk times then going once around covers at least 5k5k steps, giving 5k≤n5k \le n. For n=19n = 19 this means k≤3k \le 3. Six colours can therefore account for at most 6⋅3=186 \cdot 3 = 18 vertices, one short of 1919. So no colouring exists.

Why every n≥20n \ge 20 succeeds. For instance, 21=5+5+5+621=5+5+5+6. Put the colour strips around the polygon in that order: 12345∣12345∣12345∣123456.12345\mid12345\mid12345\mid123456. Across a seam, five consecutive colours might look like 45∣12345\mid123 or 56∣12356\mid123; they remain different, including at the seam back to the first strip. For the general construction, cut the cycle into consecutive blocks, some of length 55 and some of length 66, colouring a block of length 55 with the colours 1,2,3,4,51,2,3,4,5 in order and a block of length 66 with 1,2,3,4,5,61,2,3,4,5,6 in order. Any five consecutive vertices either lie inside one block, where the colours are distinct by construction, or straddle two blocks, taking the last jj colours of one and the first 5−j5-j of the next. The tail of a block of length 55 is {6−j,…,5}\{6-j, \ldots, 5\} and of a block of length 66 is {7−j,…,6}\{7-j, \ldots, 6\}, while the head of the next block is {1,…,5−j}\{1, \ldots, 5-j\}; in both cases the smallest entry of the tail exceeds the largest entry of the head, so the five colours are distinct. The same check covers the seam where the last block runs back into the first, since the argument used nothing about which blocks they were, only that a tail is followed by a head.

Such a decomposition exists exactly when nn can be written as 5s+6t5s + 6t with s,t≥0s, t \ge 0, and every integer n≥20n \ge 20 can: writing n=5q+rn = 5q + r with r∈{0,1,2,3,4}r \in \{0,1,2,3,4\} and q≥4q \ge 4, take t=rt = r blocks of length six and s=q−rs = q - r blocks of length five, which is legitimate because q≥4≥rq \ge 4 \ge r.

So 1919 is the largest polygon that is not colourful. (It is the last integer not of the form 5s+6t5s+6t, which is the reason the numbers five and six appear at all.)

Answer 19

Solution: IOQM 2025 Part SEP, Q28

Key idea

The four equilateral triangles and the three squares turn the twelve vertices into a 4×34 \times 3 grid, the triangles being its rows and the squares its columns, so the question is about grids with no monochromatic line.

In a regular dodecagon the equilateral triangles are {i,i+4,i+8}\{i, i+4, i+8\}, four of them, and the squares are {i,i+3,i+6,i+9}\{i, i+3, i+6, i+9\}, three of them. A vertex ii belongs to the triangle determined by i mod 4i \bmod 4 and the square determined by i mod 3i \bmod 3, and since 44 and 33 are coprime the pair (i mod 4, i mod 3)(i \bmod 4,\ i \bmod 3) determines ii. So label the vertices by a 4×34 \times 3 grid: the four triangles are the rows and the three squares are the columns.

rows: the four triangles
rows: the four triangles

Every vertex of the dodecagon appears exactly once in that grid, each row is one of the equilateral triangles and each column is one of the squares. Nothing about the dodecagon is needed from here on.

The condition is that no row and no column is monochromatic. Count by inclusion and exclusion over the set of rows and columns declared monochromatic. Fix rr rows and cc columns.

  • If r≥1r \ge 1 and c≥1c \ge 1, a chosen row meets a chosen column, so all of them share one colour: 22 choices, and the (4−r)(3−c)(4-r)(3-c) untouched cells are free.

  • If only rows are chosen, each takes its own colour: 2r2^r, with 3(4−r)3(4-r) free cells.

  • Similarly for columns alone.

So N=∑r,c(−1)r+c(4r)(3c)⋅{212r=c=0,2r 23(4−r)c=0, r≥1,2c 24(3−c)r=0, c≥1,2⋅2(4−r)(3−c)r,c≥1.N = \sum_{r,c} (-1)^{r+c}\binom4r\binom3c \cdot \begin{cases} 2^{12} & r = c = 0,\\ 2^{r}\,2^{3(4-r)} & c = 0,\ r \ge 1,\\ 2^{c}\,2^{4(3-c)} & r = 0,\ c \ge 1,\\ 2 \cdot 2^{(4-r)(3-c)} & r,c \ge 1. \end{cases} The rows-only terms give 4096−4096+1536−256+16=12964096 - 4096 + 1536 - 256 + 16 = 1296 and the columns-only terms subtract 1536−192+8=13521536 - 192 + 8 = 1352. The mixed terms, one for each rr from 11 to 44 and each cc from 11 to 33, are worth setting out rather than running together: c=1c=2c=3r=11536−1928r=2−576144−12r=396−488r=4−66−2\begin{array}{c|rrr} & c = 1 & c = 2 & c = 3 \\ \hline r = 1 & 1536 & -192 & 8 \\ r = 2 & -576 & 144 & -12 \\ r = 3 & 96 & -48 & 8 \\ r = 4 & -6 & 6 & -2 \end{array} Their total is 962962. Adding the three parts, N=1296−1352+962=906N = 1296 - 1352 + 962 = 906.

Writing N=100p+qN = 100p + q gives p=9p = 9 and q=6q = 6, so p+q=15p + q = 15.

Answer 15

Report an error on this page

Reports are stored by Netlify. See the privacy note.