Library · Between the Challenge and the Olympiad · Chapter 10
Pigeonhole, Extremal and Invariants
On this page
Problems
Problem 1
Rosie writes down the numbers 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 of the set of first 100 positive integers has the property that no two elements of sum to 125. What is the maximum possible number of elements in ?
Problem 3
Five students take a test on which any integer score from to 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 you are allowed two operations: multiply by or subtract from . For example starting with you can reach as follows: . You need two steps and you cannot do in less than two steps. Starting from , what is the least number of steps required to reach ?
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 a colour is assigned. Suppose that for any two elements of , if 15 divides then they are both assigned the same colour. What is the maximum possible number of distinct colours used?
Problem 7
A 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 such that if 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 of distinct integers is said to be balanced if . Let be any set of quadruples where and where the cardinality of is 4411. Find the least number of balanced quadruples in .
Problem 9
On each side of an equilateral triangle with side length units, where is an integer, , consider points that divide the side into 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 for which it is possible to turn all coins tail up after a finite number of moves.
Problem 10
There are blue marbles and 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 with can Alex force a win?
Problem 11
A regular polygon with 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 for which a regular polygon with vertices is not colourful.
Problem 12
The vertices of a regular dodecagon (a polygon with 12 sides) are coloured either blue or red. Let 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 can be written as where are two positive integers less than 100, find .
Solutions
Solution: IOQM 2021 Part A, Q2
Saying that the largest blue number equals how many blue numbers there are leaves no freedom at all: the blue numbers must be exactly through .
Let be the number of blue entries and the number of red ones, so .
Read the first condition carefully. The largest blue number is , so every blue number is at most , and there are of them. But there are only numbers in the whole list that are at most , namely , 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 and the smallest red number is . The second condition says this equals half the number of reds: Clearing the denominator gives , so and .
Hence , and as a check the smallest red number is , which is indeed half of .
Answer 68
Solution: PRMO 2015 Part A, Q17
Pair up the numbers that sum to ; from each pair at most one may be chosen, and every number outside the pairs is free.
The pairs with both entries in need , that is . So the pairs are of which there are . Together they use up the numbers through , and the remaining numbers through belong to no pair at all, because for those the partner exceeds .
Now the two halves of the argument. Any admissible contains at most one member of each pair, so . And is attained: take all of through together with the larger member of each pair, that is through . No two of the chosen numbers sum to , since two numbers below sum to at most , two numbers above sum to at least , and a number below paired with one above sums to at most .
Hence the maximum is .
Answer 62
Solution: IOQM 2020, Q10
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 , so that the median is the middle one, . 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:
The expression is increasing in and decreasing in each of , , and , so we would like large and the other four small. The ordering constraint is what stops us: and are not allowed to fall below . The best available compromise is therefore to send and down to , hold and at their lowest permitted value , and then read off which is largest when takes its maximum value , giving a difference of .
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 and now and are at most while and are at most , so . Taking with reaches once again. The two extremes happen to agree, so the answer is whichever way the gap opens.
Answer 40
Solution: IOQM 2024, Q20
Track what the doublings do: after of them the reachable numbers are , where 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 .
Suppose the journey uses doublings and subtractions. Follow a single subtraction: if it is performed when doublings still lie ahead, then by the end it has reduced the final value by , because each later doubling doubles whatever was taken away along with everything else. Try it on a short journey. Starting from , subtracting and then doubling twice gives , whereas doubling twice alone gives ; the removed at the start has cost by the end. Hence
Now narrow down. Doublings are the only way to grow, and , so .
First, must be odd. Working modulo , where , which is for even and for odd . Only the odd values leave a whole multiple of , so and are out, along with every other even value.
Here , so with every term at most . Since is odd and is the only odd power of two, an odd number of the terms equal . Three or more of them already mean six terms in all, since three ones leave , and two terms of at most make at most , so at least three more are needed. So take the case of exactly one , where the rest total . Two terms give at most . Three cannot reach either: one of them must be , because three terms of or less total at most , and the remaining pair would then have to make , which no two powers of two at most do. So , and is achieved by , giving .
Here is large compared with the biggest term available. From , exactly when , that is when , which holds for every . Since each term is at most , three terms could never reach , so and worse than .
So the least total is , and here is a route that achieves it: 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
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 exactly when the cards drawn include at least one even number and at least one multiple of .
So consider what can go wrong. A draw avoiding every even number can be as large as the number of odd cards, which is . A draw avoiding every multiple of can be as large as . The second is the binding constraint, so drawing cards is not enough: the non-multiples of are a genuine bad draw.
With cards both risks vanish. Only cards are not multiples of , so any must include one; and only cards are odd, so any must include an even one.
Hence cards are needed, and they suffice.
Answer 68
Solution: PRMO 2013, Q13
The rule ties remainder to remainder , and going round through the partner class ties each remainder class together, leaving eight groups.
Work modulo . The rule says that if then and share a colour.
First, the remainder : any two multiples of sum to a multiple of , so all of them share one colour.
Next, take between and . Every element of remainder must share a colour with every element of remainder , and both classes are non-empty, since is far more than . Two elements and of the same remainder are therefore forced together as well, through any element of remainder . So each pair of classes is a single colour.
That gives the groups eight of them, and nothing forces two different groups to share a colour: colouring by group satisfies the rule, since puts and in the same group by construction.
So the maximum number of colours is .
Note that being odd is what makes every non-zero class pair with a different one. For an even modulus the class would pair with itself and behave like the zero class.
Answer 8
Solution: IOQM 2021 Part A, Q12
A placement whose largest non-attacking set has rooks can be covered by whole rows or columns. That cover bounds the number of rooks, while full rows supply a placement that reaches the bound.
seven that avoid each other would need seven
The question has two halves, and they need separate arguments: show that rooks can fail, and show that 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
unit squares, and filling all of them gives rooks with no seven mutually non-attacking. So must be at least .
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 members, then every rook on the board can be covered by lines, each line a whole row or a whole column.
Fix a largest such set , with rooks. Call a row or column used if it contains a rook of ; each rook of 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 in it, if there is one, back to that rook’s row and mark that row reached. Repeat until nothing new gets marked.
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 and rooks inside it. Exchanging along that trail, taking the outside rooks into and the inside ones out, would leave a set of mutually non-attacking rooks with one more member than , 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 lines. Each reached column is used, so it carries a rook of , 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 . Every rook of 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 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 are therefore in one-to-one correspondence, and that is lines.
Stated about rows and columns of a rectangular array rather than a chessboard, that lemma is König’s theorem.
Finishing
Suppose rooks are placed and the largest mutually non-attacking set had only six members. The lemma would cover all rooks with six lines. But six lines of a board cover squares at most, holding at most rooks, one to a square. So seven mutually non-attacking rooks must exist.
Hence .
Answer 73
Solution: IOQM 2023, Q27
The ordering makes each four-element subset of give exactly one quadruple, and balanced ones correspond to two pairs with the same sum, so the worst case is minus the number of unbalanced quadruples.
Read the ordering carefully, because it is not the obvious one: the condition is . Given any four-element subset of , there is exactly one way to name its elements so that this holds, namely , , , . So the quadruples correspond exactly to four-element subsets, and there are of them. (Had the ordering been , the balanced condition would have been impossible, since then and .)
Such a quadruple is balanced when , that is . 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 and . Counting them by the common sum , if pairs from have , the number of balanced quadruples is .
There is a formula: a pair from with is fixed by its smaller member, which may be anything from up to , so Written out, for they are , and for they repeat in reverse, , by the symmetry . Hence which is .
So quadruples are unbalanced. A set of size can contain at most all of them, and the remaining members must be balanced. That many is also achieved, by taking every unbalanced quadruple together with any balanced ones. The least possible number of balanced quadruples is therefore
Answer 91
Solution: IOQM 2023, Q28
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 divides .
the rhombus turns over only the ringed pair
Start with two small nets. For , the one triangle move flips all three coins. For , performing all four unit-triangle moves flips each corner once and each side-midpoint three times, so again every coin turns over. Yet will fail: a three-colouring splits its ten coins into classes of sizes , 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 of non-negative integers with , the three coordinates being the distances to the three sides in lattice steps. The vertices of an upward unit triangle are and those of a downward one are obtained similarly.
The colouring
Put a vertex in class when . Reading off the three vertices of the upward triangle above, their values of are 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 moves. Within class , the total number of flips is exactly , since each move contributes one. On the other hand every one of the coins in that class must be flipped an odd number of times, so the total number of flips in has the same parity as . Hence
Counting the classes
Fix and let , so the row consists of the vertices with running from to and . Along the row, takes the values , which modulo cycle through all three remainders in order. So a row of length divisible by contributes equally to the three classes; a row with , whose length is , contributes one extra to ; and a row with contributes one extra to each of and .
Now suppose . As runs from to , the value runs over , and among these there are multiples of but only values congruent to . Hence the parities disagree, and turning every coin over is impossible.
If the three classes have equal size, because rotating the triangle through , which sends to , changes by modulo 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 and each of these leaves unchanged modulo , 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 : the move is available, since the rhombus it uses has its other two corners at and , both inside the triangle. Repeating it brings down to or . From , if apply and then , which takes from up to and back down to ; if instead use followed by . One of the two is available unless and are both at most , which forces , and those cases are small enough to see directly. So every vertex is joined to one on the side .
Along that side the vertices are . A rhombus joins its two opposite corners either way round, so each move may be read as or as . Applying and then backwards therefore steps by which lands back on the side and moves along in threes. Two vertices of the side lie in the same class exactly when their values of agree modulo , 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 the three classes have the same size . If is even, flip each class entirely, taking the coins in pairs. If 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 needs one move and needs all four unit triangles.
So the flipping is possible exactly when is not a multiple of . Among there are multiples of , leaving values of .
Answer 67
Solution: IOQM 2025 Part SEP, Q7
Except when only one red remains, the position is a win exactly when is odd, because the winner can always hand back a position with even and at least two reds left.
Call a position with reds remaining a win if the player about to move can force a victory. Two facts settle everything.
If 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 . We claim the position is a win exactly when is odd, and we check both directions at once by induction on . Note that may be , 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 is odd, with . If , take a red: the new position is with and even, which by induction is a loss for the opponent. If , then is odd, so ; take a blue instead, reaching with even and two reds still on the table, again a loss for the opponent. Either way the mover wins.
Suppose instead is even, with . Taking a blue reaches , where and the total is odd, a win for the opponent. Taking a red reaches : if the total is again odd and the opponent wins, and if the opponent takes the last red and wins. So every move loses.
Count the pairs with that Alex wins:
: all values of .
even, so : need odd, which is values, giving .
odd and at least , so : need even, which is values, giving .
The total is .
Answer 66
Solution: IOQM 2025 Part SEP, Q7
Two vertices of the same colour must be at least five apart around the polygon, so each colour is used at most times; with six colours that caps , 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 fails. Fix a colour and look at the vertices carrying it. Any two of them are at least apart around the cycle, so if a colour is used times then going once around covers at least steps, giving . For this means . Six colours can therefore account for at most vertices, one short of . So no colouring exists.
Why every succeeds. For instance, . Put the colour strips around the polygon in that order: Across a seam, five consecutive colours might look like or ; 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 and some of length , colouring a block of length with the colours in order and a block of length with 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 colours of one and the first of the next. The tail of a block of length is and of a block of length is , while the head of the next block is ; 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 can be written as with , and every integer can: writing with and , take blocks of length six and blocks of length five, which is legitimate because .
So is the largest polygon that is not colourful. (It is the last integer not of the form , which is the reason the numbers five and six appear at all.)
Answer 19
Solution: IOQM 2025 Part SEP, Q28
The four equilateral triangles and the three squares turn the twelve vertices into a 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 , four of them, and the squares are , three of them. A vertex belongs to the triangle determined by and the square determined by , and since and are coprime the pair determines . So label the vertices by a grid: the four triangles are the rows and the three squares are the columns.
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 rows and columns.
If and , a chosen row meets a chosen column, so all of them share one colour: choices, and the untouched cells are free.
If only rows are chosen, each takes its own colour: , with free cells.
Similarly for columns alone.
So The rows-only terms give and the columns-only terms subtract . The mixed terms, one for each from to and each from to , are worth setting out rather than running together: Their total is . Adding the three parts, .
Writing gives and , so .
Answer 15