Library · Between the Challenge and the Olympiad · Chapter 9

Counting One Thing by Counting Another

Revised Report an error
On this page
  1. Problems
  2. Solutions
  3. Solution: PRMO 2015 Part A, Q14
  4. Solution: IOQM 2023, Q8
  5. Solution: IOQM 2025 Part SEP, Q28
  6. Solution: PRMO 2014, Q20
  7. Solution: PRMO 2019, Q24
  8. Solution: IOQM 2022, Q10
  9. Solution: IOQM 2022, Q21
  10. Solution: IOQM 2023, Q7
  11. Solution: IOQM 2026, Q7
  12. Solution: IOQM 2020, Q26
  13. Solution: IOQM 2022, Q22
  14. Solution: IOQM 2025 Part SEP, Q7
  15. Solution: IOQM 2026, Q18
  16. Solution: IOQM 2021 Part B, Q3
  17. Solution: IOQM 2022, Q20
  18. Solution: IOQM 2024, Q24

Problems

Problem 1

At a party, each man danced with exactly four women and each woman danced with exactly three men. Nine men attended the party. How many women attended the party?

Problem 2

Given a 2×22 \times 2 tile and seven dominoes (2×12 \times 1 tile), find the number of ways of tiling (that is, cover without leaving gaps and without overlapping of any two tiles) a 2×72 \times 7 rectangle using some of these tiles.

Problem 3

The six faces of a cubical die are numbered with 202^0, 212^1, 222^2, 232^3, 242^4, 252^5 in such a way that the product of the numbers on any pair of opposite faces is 252^5. Two such dice are stacked one on top of another. If NN is the greatest possible sum of the 9 visible numbers (for all such arrangements of dice), find the sum of the squares of the digits of NN.

Problem 4

What is the number of ordered pairs (A,B)(A, B) where AA and BB are subsets of {1,2,…,5}\{1, 2, \ldots , 5\} such that neither A⊆BA \subseteq B nor B⊆AB \subseteq A?

Problem 5

A 1×n1 \times n rectangle (n≥1n \geq 1) is divided into nn unit (1×11 \times 1) squares. Each square of this rectangle is coloured red, blue or green. Let f(n)f(n) be the number of colourings of the rectangle in which there are an even number of red squares. What is the largest prime factor of f(9)/f(3)f(9)/f(3)? (The number of red squares can be zero.)

Problem 6

Consider the 10-digit number M=9876543210M = 9876543210. We obtain a new 10-digit number from MM according to the following rule: we can choose one or more disjoint pairs of adjacent digits in MM and interchange the digits in these chosen pairs, keeping the remaining digits in their own places. For example, from M=987‾6543‾210M = 9\underline{87}65\underline{43}210, by interchanging the 2 underlined pairs, and keeping the others in their places, we get M1=978‾6534‾210M_1 = 9\overline{78}65\overline{34}210. Note that any number of (disjoint) pairs can be interchanged. Find the number of new numbers that can be so obtained from MM.

Problem 7

An ant is at a vertex of a cube. Every 10 minutes it moves to an adjacent vertex along an edge. If NN is the number of one hour journeys that end at the starting vertex, find the sum of the squares of the digits of NN.

Problem 8

Unconventional dice are to be designed such that the six faces are marked with numbers from 1 to 6 with 1 and 2 appearing on opposite faces. Further, each face is coloured either red or yellow with opposite faces always of the same colour. Two dice are considered to have the same design if one of them can be rotated to obtain a dice that has the same numbers and colours on the corresponding faces as the other one. Find the number of distinct dice that can be designed.

Problem 9

Find the number of positive integers nn satisfying all the following conditions:

(a) The digits of nn lie in the set {1,2,4,8}\{1, 2, 4, 8\}. (Digits may be repeated.)

(b) The sum of the digits is 1414.

(c) If 11 occurs as a digit, then it can occur only immediately to the right of 88.

Problem 10

In the figure below, 44 of the 66 discs are to be coloured black and 22 are to be coloured white. Two colourings that can be obtained from one another by a rotation or a reflection of the entire figure are considered the same. There are only four such colourings for the given two colours, as shown in Figure 1. In how many ways can we colour the 6 discs such that 2 are coloured black, 2 are coloured white, 2 are coloured blue with the given identification condition?

three corners, three edge midpoints
three corners, three edge midpoints

Problem 11

A binary sequence is a sequence in which each term is equal to 0 or 1. A binary sequence is called friendly if each term is adjacent to at least one term that is equal to 1. For example, the sequence 0,1,1,0,0,1,1,10, 1, 1, 0, 0, 1, 1, 1 is friendly. Let FnF_n denote the number of friendly binary sequences with nn terms. Find the smallest positive integer n≥2n \geq 2 such that Fn>100F_n > 100.

Problem 12

Let NN be the number of nine-digit integers that can be obtained by permuting the digits of 223334444223334444 and which have at least one 33 to the right of the right-most occurrence of 44. What is the remainder when NN is divided by 100100?

Problem 13

In the plane let the positive end of the xx-axis be directed towards East and the positive end of the yy-axis be directed towards North. Suppose you are at (0,0)(0,0) and you want to go to (7,12)(7,12). At every move you are allowed to move unit length towards East or unit length towards North from your current position but you are not allowed to visit any point (h,k)(h,k) where both h,kh, k are odd. Find the number of such paths nn.

Problem 14

Let PP be a regular polygon with 88 vertices. By a labelling of PP we mean an assignment of integers 1,2,…,81, 2, \ldots, 8 to the vertices in some order. A labelling is considered good if the path consisting of line segments 11 to 22, 22 to 33, … and 77 to 88 does not self-intersect. If NN is the number of good labellings, what is the remainder when NN is divided by 100100?

Problem 15

For a positive integer NN, let T(N)T(N) denote the number of arrangements of the integers 1,2,…,N1, 2, \ldots, N into a sequence a1,a2,…,aNa_1, a_2, \ldots, a_N such that ai>a2ia_i > a_{2i} for all ii, 1≤i<2i≤N1 \leq i < 2i \leq N and ai>a2i+1a_i > a_{2i+1}, for all ii, 1≤i<2i+1≤N1 \leq i < 2i + 1 \leq N. For example, T(3)T(3) is 22, since the possible arrangements are 321321 and 312312.

  1. Find T(7)T(7).

  2. If KK is the largest non-negative integer so that 2K2^K divides T(2n−1)T(2^n - 1), show that K=2n−n−1K = 2^n - n - 1.

  3. Find the largest non-negative integer KK so that 2K2^K divides T(2n+1)T(2^n + 1).

image

Problem 16

For an integer n≥3n \geq 3 and a permutation σ=(p1,p2,…,pn)\sigma = (p_1, p_2, \ldots, p_n) of {1,2,…,n}\{1, 2, \ldots, n\}, we say plp_l is a landmark point if 2≤l≤n−12 \leq l \leq n-1 and (pl−1−pl)(pl+1−pl)>0(p_{l-1} - p_l)(p_{l+1} - p_l) > 0. For example, for n=7n = 7, the permutation (2,7,6,4,5,1,3)(2, 7, 6, 4, 5, 1, 3) has four landmark points: p2=7p_2 = 7, p4=4p_4 = 4, p5=5p_5 = 5 and p6=1p_6 = 1. For a given n≥3n \geq 3, let L(n)L(n) denote the number of permutations of {1,2,…,n}\{1, 2, \ldots, n\} with exactly one landmark point. Find the maximum n≥3n \geq 3 for which L(n)L(n) is a perfect square.

Problem 17

Consider the set FF of all polynomials whose coefficients are in the set of {0,1}\{0, 1\}. Let q(x)=x3+x+1q(x) = x^3 + x + 1. The number of polynomials p(x)p(x) in FF of degree 1414 such that the product p(x)q(x)p(x)q(x) is also in FF is:

Problem 18

Consider a sequence of real numbers of finite length. Consecutive four term averages of this sequence are strictly increasing, but consecutive seven term averages are strictly decreasing. What is the maximum possible length of such a sequence?

Solutions

Solution: PRMO 2015 Part A, Q14

Key idea

Count the dancing pairs twice, once from the men’s side and once from the women’s, and the two counts must agree.

Call a pair consisting of a man and a woman who danced together a dancing pair, and let WW be the number of women. Counting these pairs from the men’s side, each of the 99 men appears in exactly 44 of them, so there are 9×4=369 \times 4 = 36 pairs. Counting from the women’s side, each woman appears in exactly 33, so there are 3W3W pairs.

The same collection has been counted both times, so 3W=36,W=12.3W = 36, \qquad W = 12.

This is double counting in its purest form, and the shape recurs constantly: whenever a problem gives you a fixed number of connections at each end of a two-sided relationship, count the connections themselves and set the two totals equal.

Answer 12

Solution: IOQM 2023, Q8

Key idea

Split the count by whether the square tile is used; without it the tilings are counted by the Fibonacci numbers, and with it the square’s position cuts the strip into two shorter strips tiled by dominoes alone.

The two tilings of a 2\times2 strip.
The two tilings of a 2×22\times2 strip.

Let f(k)f(k) be the number of ways to tile a 2×k2 \times k rectangle with dominoes only. Looking at the leftmost column, either one vertical domino fills it, leaving 2×(k−1)2 \times (k-1), or two horizontal dominoes fill the first two columns, leaving 2×(k−2)2 \times (k-2). So f(k)=f(k−1)+f(k−2),f(0)=1, f(1)=1,f(k) = f(k-1) + f(k-2), \qquad f(0) = 1,\ f(1) = 1, giving 1,1,2,3,5,8,13,211, 1, 2, 3, 5, 8, 13, 21 for k=0k = 0 through 77. In particular there are f(7)=21f(7) = 21 tilings that use dominoes alone, and they use exactly seven dominoes, which is what we have.

Now suppose the 2×22 \times 2 tile is used. Only one such tile is available, so it is used at most once. It covers two adjacent columns, say columns ii and i+1i+1 with 1≤i≤61 \le i \le 6, and it splits the strip into a 2×(i−1)2 \times (i-1) piece on the left and a 2×(6−i)2 \times (6-i) piece on the right, each tiled by dominoes alone. The number of tilings using the square is therefore ∑i=16f(i−1) f(6−i)=1⋅8+1⋅5+2⋅3+3⋅2+5⋅1+8⋅1=38.\sum_{i=1}^{6} f(i-1)\,f(6-i) = 1\cdot 8 + 1 \cdot 5 + 2 \cdot 3 + 3 \cdot 2 + 5 \cdot 1 + 8 \cdot 1 = 38. Each of these uses five dominoes, comfortably within the seven available.

The two cases are disjoint and cover everything, so the answer is 21+38=5921 + 38 = 59.

Answer 59

Solution: IOQM 2025 Part SEP, Q28

Key idea

Only three faces are hidden, and two of them are opposite faces of the lower die, so their sum is at least 4+8=124+8 = 12; the third hidden face should be the smallest number, 11.

Three faces are hidden: the lower bottom and the two touching faces.
Three faces are hidden: the lower bottom and the two touching faces.

The exponents on opposite faces add to 55, so opposite faces carry {1,32}\{1,32\}, {2,16}\{2,16\} or {4,8}\{4,8\}. Each die carries all six numbers, with total 1+2+4+8+16+32=63,1+2+4+8+16+32 = 63, so the two dice together carry 126126.

Stacking hides exactly three faces: the bottom face of the lower die, the top face of the lower die and the bottom face of the upper die. The first two are opposite faces of the same die, so their sum is one of 1+32=33,2+16=18,4+8=12,1 + 32 = 33, \qquad 2 + 16 = 18, \qquad 4 + 8 = 12, and the smallest is 1212. The third hidden face is any face of the upper die and can be as small as 11.

So the least possible hidden total is 12+1=1312 + 1 = 13 and N=126−13=113.N = 126 - 13 = 113. The sum of the squares of the digits is 1+1+9=111 + 1 + 9 = 11.

Answer 11

Solution: PRMO 2014, Q20

Key idea

Count each element’s four possible states independently, then subtract the pairs with A⊆BA \subseteq B or B⊆AB \subseteq A by inclusion-exclusion.

Build a pair (A,B)(A,B) element by element. Each of the five elements is in AA only, in BB only, in both, or in neither, four independent choices, so there are 45=10244^5 = 1024 ordered pairs altogether.

Now count the bad ones. For A⊆BA \subseteq B, each element must avoid the state “in AA only”, leaving three choices, so there are 35=2433^5 = 243 such pairs, and likewise 243243 with B⊆AB \subseteq A. Pairs counted twice are those with both inclusions, that is A=BA = B, of which there are 25=322^5 = 32. By inclusion-exclusion the bad pairs number 243+243−32=454.243 + 243 - 32 = 454.

Hence the answer is 1024−454=570.1024 - 454 = 570.

Answer 570

Solution: PRMO 2019, Q24

Key idea

Count the colourings once with every colouring positive, and once with an odd number of reds carrying a minus sign. Adding the two totals isolates the even-red count.

For one square, blue and green contribute +1+1 each and red contributes −1-1, so the signed total is 1+1−1=11+1-1=1, while the ordinary total is 33. Adding gives 44, twice the number of choices with an even number of reds. The same separation can work with any number of squares. The ordinary total number of colourings is 3n3^n. Now attach to each colouring the sign (−1)#red(-1)^{\#\text{red}} and add: ∑colourings(−1)#red=(1+1−1)n=1,\sum_{\text{colourings}} (-1)^{\#\text{red}} = (1 + 1 - 1)^n = 1, because each square independently contributes +1+1 for either of the two non-red colours and −1-1 for red. The left-hand side is (even-red count) minus (odd-red count), while the total is their sum, so f(n)=3n+12.f(n) = \frac{3^n + 1}{2}.

Therefore f(9)f(3)=39+133+1=273+127+1=272−27+1=703,\frac{f(9)}{f(3)} = \frac{3^9 + 1}{3^3 + 1} = \frac{27^3 + 1}{27 + 1} = 27^2 - 27 + 1 = 703, using a3+1=(a+1)(a2−a+1)a^3 + 1 = (a+1)(a^2 - a + 1) with a=27a = 27, which spares the division of 98429842 by 1414. Finally 703=19×37703 = 19 \times 37, so the largest prime factor is 3737.

Answer 37

Solution: IOQM 2022, Q10

Key idea

A choice of disjoint adjacent pairs is a matching on a path of ten vertices, and those are counted by the Fibonacci numbers.

The highlighted edges swap positions 2,3 and 6,7 without sharing a position.
The highlighted edges swap positions 2,32,3 and 6,76,7 without sharing a position.

The ten digits of MM are all different, so two different choices of swaps always produce two different numbers, and we may count the choices directly.

For three positions, there are just three disjoint-swap choices: no swap, swap positions 1,21,2, or swap positions 2,32,3. Both swaps together are forbidden because they share position 22. Think of the ten digit positions as vertices of a path, with an edge joining each adjacent pair. Choosing disjoint adjacent pairs to swap is exactly choosing a set of edges no two of which share a vertex, that is a matching. Let fnf_n be the number of matchings on a path of nn vertices. Looking at the last vertex, either it is unmatched, leaving fn−1f_{n-1}, or it is matched to its neighbour, leaving fn−2f_{n-2}. So fn=fn−1+fn−2,f1=1,f2=2,f_n = f_{n-1} + f_{n-2}, \qquad f_1 = 1, \quad f_2 = 2, which is the Fibonacci sequence shifted along. Running it out, f3=3f_3 = 3, f4=5f_4 = 5, and onwards to f10=89f_{10} = 89.

One of those 8989 choices is the empty one, which leaves MM unchanged and so produces no new number. The count of new numbers is 89−1=8889 - 1 = 88.

Answer 88

Solution: IOQM 2022, Q21

Key idea

Track how many ways the ant can be at the start, at a neighbour, at a face-diagonal vertex, or at the opposite corner. Four numbers suffice, because the cube looks the same from every vertex.

each vertex carries its distance from the start; each arrow counts neighbours
each vertex carries its distance from the start;
each arrow counts neighbours

An hour is six moves of ten minutes each, so we want the number of closed walks of length six from a fixed vertex of a cube.

Classify each vertex by its distance from the start: there is 11 vertex at distance 00, three at distance 11, three at distance 22, and one at distance 33. Because every vertex of the cube looks the same as every other, with three neighbours apiece, the count of walks depends only on this class, so let (at,bt,ct,dt)(a_t, b_t, c_t, d_t) record how many length-tt walks end in each class. From the adjacency, a vertex at distance 00 has all three neighbours at distance 11, a vertex at distance 11 has one neighbour at distance 00 and two at distance 22, a vertex at distance 22 has two neighbours at distance 11 and one at distance 33, and the vertex at distance 33 has all three neighbours at distance 22. A walk arriving in a class came from a neighbouring class, so at+1=bt,bt+1=3at+2ct,ct+1=2bt+3dt,dt+1=ct.a_{t+1} = b_t, \quad b_{t+1} = 3a_t + 2c_t, \quad c_{t+1} = 2b_t + 3d_t, \quad d_{t+1} = c_t.

Starting from (1,0,0,0)(1,0,0,0) and stepping six times: tatbtctdt010001030023060302106421060050183060618305460\begin{array}{c|cccc} t & a_t & b_t & c_t & d_t \\ \hline 0 & 1 & 0 & 0 & 0 \\ 1 & 0 & 3 & 0 & 0 \\ 2 & 3 & 0 & 6 & 0 \\ 3 & 0 & 21 & 0 & 6 \\ 4 & 21 & 0 & 60 & 0 \\ 5 & 0 & 183 & 0 & 60 \\ 6 & 183 & 0 & 546 & 0 \end{array} Half the entries are zero because every move changes the distance by one, so after an even number of moves the ant is at distance 00 or 22. The number of walks that finish where they started is N=a6=183N = a_6 = 183.

The question asks for the sum of the squares of the digits of NN, which is 12+82+32=1+64+9=741^2 + 8^2 + 3^2 = 1 + 64 + 9 = 74.

Answer 74

Solution: IOQM 2023, Q7

Key idea

Because all six numbers are different, no rotation other than the identity can fix a design, so the 2424 rotations cut the count of labelled coloured dice by exactly 2424.

First count dice with the faces labelled and coloured in space, ignoring the identification by rotation. The face carrying 11 can be any of the 66, its opposite face must carry 22, and the remaining four numbers can be placed on the remaining four faces in 4!=244! = 24 ways. That gives 6⋅24=1446 \cdot 24 = 144 numberings. Colouring is independent: the three pairs of opposite faces each take one of two colours, so 23=82^3 = 8 colourings. In total there are 144⋅8=1152144 \cdot 8 = 1152 labelled coloured dice sitting in space.

Now bring in the rotations. A rotation of the cube is fixed by saying where one chosen face goes, which is any of the 66 faces, and then how that face is turned, which is any of 44 quarter turns; so there are 6⋅4=246 \cdot 4 = 24 of them. Two of our dice have the same design exactly when a rotation carries one to the other. The count of designs would be 1152/241152/24 provided no rotation other than the identity leaves a die unchanged, and that is where the distinct numbers help: a non-identity rotation moves some face to a different face, and those two faces carry different numbers, so the die is changed. Every family of dice that count as the same therefore has exactly 2424 members and number of designs=115224=48.\text{number of designs} = \frac{1152}{24} = 48.

If it helps to see the same answer built up rather than divided down, fix 11 on top and 22 below, which uses up the freedom to rotate the die as a whole except for the four turns about the vertical axis. The four side faces can be filled with 3,4,5,63, 4, 5, 6 in 4!=244! = 24 ways, and those four turns identify them in groups of four, leaving 66 numberings. Multiply by the 88 colourings to get 4848.

Answer 48

Solution: IOQM 2026, Q7

Key idea

A 11 always travels with the 88 in front of it, and the pair 8181 adds 99, an odd amount among even digits. With an even total of 1414 no 11 can appear, and what is left is counting the ordered ways to add 22s, 44s and 88s to 1414.

Condition (c) says every 11 sits immediately after an 88. Glue each such 11 to its 88, and the number becomes a row of blocks 22, 44, 88 and 8181, whose digit sums are 22, 44, 88 and 99. All but the last are even, and the total is the even number 1414, so the number of 8181 blocks is even. Two of them already add up to 1818, which is too much, so there are none, and nn uses only the digits 22, 44 and 88.

Halve everything: we want the number of ordered ways to write 77 as a sum of 11s, 22s and 44s. Write f(m)f(m) for the number of ways to make a total of mm. The first part is 11, 22 or 44, and what follows is any arrangement of the remainder, so f(m)=f(m−1)+f(m−2)+f(m−4),f(m) = f(m-1) + f(m-2) + f(m-4), where f(0)=1f(0) = 1 (the empty sum) and ff of a negative number is 00. Each entry of the table after the first is the sum of the entries one, two and four places to its left: m01234567f(m)11236101831\begin{array}{c|cccccccc} m & 0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 \\ \hline f(m) & 1 & 1 & 2 & 3 & 6 & 10 & 18 & 31 \end{array} and in particular f(7)=18+10+3=31f(7) = 18 + 10 + 3 = 31.

Each way of making 77, read left to right and doubled, is the list of digits of exactly one nn, so there are 3131 numbers.

Answer 31

Solution: IOQM 2020, Q26

Key idea

Count colourings by averaging over the six symmetries. The two rotations fix nothing at all, because a rotation would force three discs to share a colour and no colour has three discs.

A reflection swaps the two a positions and the two b positions, while fixing the two c positions.
A reflection swaps the two aa positions and the two bb positions, while fixing the two cc positions.

The six discs sit in a triangular array, three at the corners and three at the midpoints of the sides, and the symmetries of that array are the six symmetries of an equilateral triangle: the identity, two rotations, and three reflections. Two colourings count as the same exactly when one symmetry carries one to the other, so what we are counting is families of colourings, each family holding the ones the symmetries carry into each other.

The obvious move is to count the 9090 labelled colourings and divide by 66, and it fails, because 90/6=1590/6 = 15 is not the answer. It fails because the six symmetries do not always give six different labelled colourings: a colouring that a reflection leaves alone is reached in fewer than six ways, so dividing by six undercounts it. What is needed is a division that adjusts for exactly that.

The tool is to average, over the six symmetries, the number of colourings each one leaves unchanged, and since that is not a school result, here is why it works. Count the pairs (g,C)(g, C) in which the symmetry gg leaves the colouring CC unchanged, in two ways. Summing over gg gives the total of the fixed-colouring counts. Summing instead over CC: fix a colouring CC and let SS be the set of symmetries leaving it unchanged. Two symmetries gg and hh send CC to the same colouring exactly when applying hh and then undoing gg leaves CC unchanged, so the six symmetries fall into groups of size ∣S∣|S|, one group for each colouring in the family of CC. The order matters: doing it the other way round tests a different symmetry, and for the reflections that test gives the wrong answer. Hence ∣S∣|S| times the size of that family is 66, so each colouring in a family contributes 6/(family size)6 / (\text{family size}), and the whole family contributes 66. Adding over families, the two counts give number of families×6=∑g(colourings g fixes),\text{number of families} \times 6 = \sum_g \bigl(\text{colourings } g \text{ fixes}\bigr), which is the averaging rule.

Take the symmetries in turn. The identity leaves every colouring unchanged, and the number of ways to give two discs each of three colours to six labelled positions is 6!2! 2! 2!=90\tfrac{6!}{2!\,2!\,2!} = 90.

The two rotations fix nothing. A rotation through 120∘120^\circ permutes the three corners in a single cycle and the three midpoints in another, so any colouring it leaves unchanged must give all three corners one colour and all three midpoints another. That would need three discs of some colour, and we have only two of each, so the count is 00 for each rotation.

Each reflection fixes one corner and the midpoint of the opposite side, while swapping the other two corners with each other and the other two midpoints with each other. A colouring unchanged by it must give the swapped corner pair a single colour and the swapped midpoint pair a single colour, and those two colours must differ, since otherwise that colour would appear four times. The remaining colour then goes to the two fixed discs, which is exactly the two we have left. So there are 3×2=63 \times 2 = 6 such colourings for each of the three reflections.

Averaging over the six symmetries, 90+0+0+6+6+66=1086=18.\frac{90 + 0 + 0 + 6 + 6 + 6}{6} = \frac{108}{6} = 18.

Answer 18

Solution: IOQM 2022, Q22

Key idea

The two neighbours of an interior term lie in the same parity class of positions. Split the sequence into its odd and even positions: each must avoid two consecutive zeros, with the end conditions fixing a few ones.

Read the condition position by position. The first term needs b2=1b_2 = 1 and the last needs bn−1=1b_{n-1} = 1, those being their only neighbours. For an interior position ii, the requirement is that bi−1b_{i-1} and bi+1b_{i+1} are not both 00.

That last condition is the useful one, because i−1i-1 and i+1i+1 have the same parity and are consecutive within their parity. As ii runs over 2,…,n−12, \ldots, n-1, the pairs (i−1,i+1)(i-1, i+1) run over every consecutive pair of the odd-indexed terms and every consecutive pair of the even-indexed terms. So a sequence is friendly exactly when b2=1,bn−1=1,b_2 = 1, \qquad b_{n-1} = 1, and neither the odd-indexed subsequence nor the even-indexed subsequence contains two consecutive zeros. The two subsequences are otherwise independent, so the count is a product.

It is worth splitting one sequence by hand before going on. For n=8n = 8 take i12345678bi11011011\begin{array}{r|cccccccc} i & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 \\ \hline b_i & 1 & 1 & 0 & 1 & 1 & 0 & 1 & 1 \end{array} The odd positions carry 1,0,1,11, 0, 1, 1 and the even positions carry 1,1,0,11, 1, 0, 1. Neither has two zeros in a row, the required b2b_2 and b7b_7 are both 11, and one may check position by position that the sequence really is friendly. Notice that the two rows never look at each other.

The building block is the number of binary strings of length LL with no two consecutive zeros, which is Fib⁡L+2\operatorname{Fib}_{L+2} with Fib⁡1=Fib⁡2=1\operatorname{Fib}_1 = \operatorname{Fib}_2 = 1: the first term is 00 or 11, and the two cases leave strings of length L−2L-2 and L−1L-1 with the same property. Fixing one end to be a 11 costs one step of the recursion, giving Fib⁡L+1\operatorname{Fib}_{L+1}; fixing both ends gives Fib⁡L\operatorname{Fib}_L.

n=2mn = 2m

The odd positions are 1,3,…,2m−11, 3, \ldots, 2m-1 and the even ones 2,4,…,2m2, 4, \ldots, 2m, both of length mm. The condition bn−1=1b_{n-1} = 1 fixes the last odd term and b2=1b_2 = 1 fixes the first even term, so each subsequence contributes Fib⁡m+1\operatorname{Fib}_{m+1} and F2m=Fib⁡m+1 2.F_{2m} = \operatorname{Fib}_{m+1}^{\,2}.

n=2m+1n = 2m+1

Now the odd positions number m+1m+1 and carry no fixed term, contributing Fib⁡m+3\operatorname{Fib}_{m+3}; the even positions number mm and have both ends fixed, since b2b_2 is the first and bn−1=b2mb_{n-1} = b_{2m} the last, contributing Fib⁡m\operatorname{Fib}_m. So F2m+1=Fib⁡m+3Fib⁡m.F_{2m+1} = \operatorname{Fib}_{m+3}\operatorname{Fib}_m.

Now evaluate. With m=5m = 5 the even case gives F10=Fib⁡6 2=82=64F_{10} = \operatorname{Fib}_6^{\,2} = 8^2 = 64, still below 100100, and the odd case gives F11=Fib⁡8Fib⁡5=21⋅5=105>100.F_{11} = \operatorname{Fib}_8 \operatorname{Fib}_5 = 21 \cdot 5 = 105 > 100. Both FnF_n formulas increase with nn, so the smallest such nn is n=11n = 11.

Answer 11

Solution: IOQM 2025 Part SEP, Q7

Key idea

Count the opposite: the arrangements with no 33 after the last 44 are exactly those ending in a 44 followed only by twos, and there are just three shapes to count.

The digits are two 22s, three 33s and four 44s, so the total number of arrangements is 9!2! 3! 4!=362880288=1260.\frac{9!}{2!\,3!\,4!} = \frac{362880}{288} = 1260.

Now count the arrangements in which no 33 lies to the right of the last 44. Everything after the last 44 is then a 22, say kk of them with k∈{0,1,2}k \in \{0,1,2\}. Such an arrangement is completely described by choosing kk, placing a 44 in position 9−k9-k, filling the last kk places with twos, and arranging the remaining digits, which are three 33s, three 44s and 2−k2-k twos, in the first 8−k8-k places. So the count is ∑k=02(8−k)!(2−k)! 3! 3!=8!2! 3! 3!+7!1! 3! 3!+6!0! 3! 3!,\sum_{k=0}^{2} \frac{(8-k)!}{(2-k)!\,3!\,3!} = \frac{8!}{2!\,3!\,3!} + \frac{7!}{1!\,3!\,3!} + \frac{6!}{0!\,3!\,3!}, which is 560+140+20=720560 + 140 + 20 = 720.

Hence N=1260−720=540N = 1260 - 720 = 540, and the remainder on division by 100100 is 4040.

Answer 40

Solution: IOQM 2025 Part SEP, Q28

Key idea

From a point with one odd coordinate the next step is forced, so the whole path is decided at the points with both coordinates even, and it moves in double steps.

crossed points are barred, so the walk hops between the filled dots
crossed points are barred,
so the walk hops between the filled dots

The forbidden points are those with both coordinates odd. Look at where you can be.

  • At (even,even)(\text{even}, \text{even}) either step is legal.

  • At (odd,even)(\text{odd}, \text{even}) a step North would land on two odd coordinates, so you must go East, arriving at (even,even)(\text{even}, \text{even}).

  • At (even,odd)(\text{even}, \text{odd}) you must likewise go North.

So from an even-even point every choice commits you to two steps, taking you either two East or two North, and back to an even-even point.

The journey therefore consists of double steps from (0,0)(0,0) to the last even-even point, and since the destination is (7,12)(7,12), with 77 odd and 1212 even, that last point is (6,12)(6,12) and the journey finishes with a single step East. The double steps take you from (0,0)(0,0) to (6,12)(6,12), which needs 33 double steps East and 66 double steps North in some order: (93)=84.\binom{9}{3} = 84.

Answer 84

Solution: IOQM 2026, Q18

Key idea

Build the path one vertex at a time. The vertices already used always form an unbroken run around the octagon with the current vertex at one end, so every step has just two choices, one at each end of the gap.

image

A labelling is a path through all eight vertices, visited in the order 1,2,…,81, 2, \ldots, 8. The claim is that in a good labelling, at every stage, the vertices visited so far are consecutive around the octagon and the current vertex is at one end of that run.

At the start the run is one vertex. Suppose the claim holds, the current vertex is cc, and the unvisited vertices form the complementary run UU. Suppose the path next goes to a vertex ww of UU that is not one of its two ends. The segment cwcw is a chord with unvisited vertices on both sides of it: those of UU between cc and ww, and those beyond ww. The rest of the path starts at ww and has to visit both sides, so at some moment it steps along a segment whose ends lie strictly on opposite sides of the chord cwcw. In a convex polygon such a segment crosses cwcw, and the labelling is not good. So the path moves to an end of UU, and the claim holds one step later.

Conversely, a step to an end of UU crosses nothing already drawn. If the end is next to cc the step is a side of the octagon. If it is the other end, every visited vertex other than cc lies on one side of the new chord, so every earlier segment does too, and none can cross it.

So the good labellings are counted by their choices. There are 88 places for vertex 11. Each of vertices 22 to 77 has two choices, the two ends of UU, which are different while UU has at least two vertices. Vertex 88 is forced. Hence N=8×26=512,N = 8 \times 2^6 = 512, and the remainder on division by 100100 is 1212.

Answer 12

Solution: IOQM 2021 Part B, Q3

Key idea

Hang the numbers on a binary tree, aia_i above a2ia_{2i} and a2i+1a_{2i+1}. The condition says every number beats the two below it, so the largest sits at the top and the two branches are independent copies of the same problem; that gives a product recurrence, and one short lemma counts the twos in a factorial.

What the condition means

Place a1,a2,…,aNa_1, a_2, \ldots, a_N at the nodes of a binary tree, with aia_i the parent of a2ia_{2i} and a2i+1a_{2i+1}. The two conditions say precisely that every number is larger than the two hanging beneath it. So a1a_1, at the top, is the largest of all, and once it is placed the two branches have nothing to do with each other: each is the same problem on fewer nodes.

choose which \ell of the rest go left, then repeat on each side
choose which ℓ\ell of the rest go left, then repeat on each side

That picture is the whole method. Choosing which numbers go left and which go right is free, and then each branch is counted the same way, so every count below will be a binomial coefficient times two smaller counts. An arrangement of this kind is called a heap, and the name will not be asked to do any work beyond that.

(a) T(7)T(7)

For N=7N = 7 the tree is the full tree of three levels: a root with two subtrees of three nodes each. The root must hold 77. Of the remaining six numbers, choose three for the left subtree in (63)\binom63 ways, and arrange each subtree in T(3)=2T(3) = 2 ways. Hence T(7)=(63)⋅T(3)2=20⋅4=80.T(7) = \binom63 \cdot T(3)^2 = 20 \cdot 4 = 80.

A lemma on powers of two

For example, 6!=720=24⋅456!=720=2^4\cdot45 contains four factors of 22. The number 66 is 110110 in binary, so it has two ones, and 4=6−24=6-2. This is the pattern we will prove. Write v(m)v(m) for the exponent of 22 in mm, and s(m)s(m) for the number of ones when mm is written in binary. The claim is v(m!)=m−s(m).v(m!) = m - s(m).

The proof is an induction that splits on whether mm is even or odd, and it needs only two observations of each kind. Among 1,2,…,2k1, 2, \ldots, 2k the odd numbers carry no factor of 22 at all, while the even ones are 2,4,…,2k2, 4, \ldots, 2k, whose product is 2k⋅k!2^k \cdot k!. So v((2k)!)=k+v(k!),v((2k+1)!)=v((2k)!),v\bigl((2k)!\bigr) = k + v(k!), \qquad v\bigl((2k+1)!\bigr) = v\bigl((2k)!\bigr), the second because the extra factor 2k+12k+1 is odd. On the other side, doubling a number in binary just appends a zero and adding one after that turns it into a one, so s(2k)=s(k),s(2k+1)=s(k)+1.s(2k) = s(k), \qquad s(2k+1) = s(k) + 1.

Now induct. The claim holds at m=1m = 1, where both sides are 00. Suppose it holds below mm. If m=2km = 2k then v(m!)=k+(k−s(k))=2k−s(2k)=m−s(m),v(m!) = k + \bigl(k - s(k)\bigr) = 2k - s(2k) = m - s(m), and if m=2k+1m = 2k+1 then v(m!)=v((2k)!)=2k−s(k)=(2k+1)−(s(k)+1)=m−s(m).v(m!) = v\bigl((2k)!\bigr) = 2k - s(k) = (2k+1) - \bigl(s(k)+1\bigr) = m - s(m). That is the lemma, and nothing outside it is used below.

One consequence is worth recording now, for n≥2n\ge2. Since s(2n−1+1)=2s(2^{n-1}+1) = 2 and s(2n−1−1)=n−1s(2^{n-1}-1) = n-1, v(2n2n−1+1)=(2n−1)−(2n−1−1)−(2n−1−n)=n.v\binom{2^n}{2^{n-1}+1} = \left(2^n - 1\right) - \left(2^{n-1} - 1\right) - \left(2^{n-1} - n\right) = n.

(b) Full trees

For N=2n−1N = 2^n - 1 the tree is full, and the same argument as in part (a) gives T(2n−1)=(2n−22n−1−1) T(2n−1−1)2.T\left(2^n - 1\right) = \binom{2^n - 2}{2^{n-1} - 1}\,T\left(2^{n-1} - 1\right)^2. The exponent of 22 in that binomial coefficient is n−1n - 1: by the lemma it is (2n−2−s(2n−2))−2(2n−1−1−s(2n−1−1))\left(2^n - 2 - s(2^n-2)\right) - 2\left(2^{n-1} - 1 - s(2^{n-1}-1)\right), and s(2n−2)=n−1=s(2n−1−1)s(2^n - 2) = n - 1 = s(2^{n-1}-1), so the whole thing is n−1n-1.

Writing tnt_n for the exponent of 22 in T(2n−1)T(2^n - 1), the recurrence reads tn=2tn−1+(n−1),t1=0.t_n = 2t_{n-1} + (n-1), \qquad t_1 = 0. And tn=2n−n−1t_n = 2^n - n - 1 satisfies it, since 2(2n−1−(n−1)−1)+(n−1)=2n−n−1,2\left(2^{n-1} - (n-1) - 1\right) + (n-1) = 2^n - n - 1, with t1=2−1−1=0t_1 = 2 - 1 - 1 = 0 correct. So K=2n−n−1K = 2^n - n - 1, as required.

(c) One node more than a power of two

For n≥2n\ge2 and N=2n+1N = 2^n + 1, the tree has its root, a left subtree of 2n−1+12^{n-1}+1 nodes and a right subtree of 2n−1−12^{n-1}-1 nodes. The same splitting gives T(2n+1)=(2n2n−1+1) T(2n−1+1)T(2n−1−1),T\left(2^n + 1\right) = \binom{2^n}{2^{n-1}+1}\,T\left(2^{n-1}+1\right)T\left(2^{n-1}-1\right), which one may check at n=2n = 2: T(5)=(43)T(3)T(1)=4⋅2⋅1=8T(5) = \binom43 T(3)T(1) = 4 \cdot 2 \cdot 1 = 8.

Let sns_n be the exponent of 22 in T(2n+1)T(2^n+1). Using the consequence of the lemma recorded above and part (b), sn=n+sn−1+tn−1=n+sn−1+2n−1−n=sn−1+2n−1.s_n = n + s_{n-1} + t_{n-1} = n + s_{n-1} + 2^{n-1} - n = s_{n-1} + 2^{n-1}. Since T(3)=2T(3) = 2 gives s1=1s_1 = 1, summing the geometric series leaves sn=1+(2+4+⋯+2n−1)=2n−1.s_n = 1 + \left(2 + 4 + \cdots + 2^{n-1}\right) = 2^n - 1.

So the largest KK with 2K2^K dividing T(2n+1)T(2^n+1) is 2n−12^n - 1.

Answer proof

Solution: IOQM 2022, Q20

Key idea

Counting gives L(n)=2n−4L(n) = 2^n - 4, and the finish is a congruence: 2k−12^k - 1 is 77 modulo 88 once k≥3k \geq 3, while every square is 00, 11 or 44.

First identify what a landmark is. The condition (pl−1−pl)(pl+1−pl)>0(p_{l-1}-p_l)(p_{l+1}-p_l) > 0 says the two neighbours lie on the same side of plp_l, so plp_l is either larger than both, a peak, or smaller than both, a valley. Exactly one landmark therefore means the permutation rises to a single peak and then falls, or falls to a single valley and then rises.

A small peak example is 2,4,3,12,4,3,1: after choosing {2}\{2\} to lie left of the maximum 44, the increasing left part and decreasing right part are forced. A valley example is 3,1,2,43,1,2,4. 2,4⏟rising∣4,3,1⏟falling3,1⏟falling∣1,2,4⏟rising.\underbrace{2,4}_{\text{rising}}\mid\underbrace{4,3,1}_{\text{falling}} \qquad\underbrace{3,1}_{\text{falling}}\mid\underbrace{1,2,4}_{\text{rising}}. The shared peak or valley is repeated in the display only to mark the two runs. Count the peak case. The peak is larger than everything around it and the sequence is increasing up to it and decreasing after, so the peak is the largest value, nn. The elements to its left are then determined as a set, since they must appear in increasing order, and likewise those to its right. So a permutation of this kind is exactly a choice of which elements of {1,…,n−1}\{1, \ldots, n-1\} go to the left. That choice may not be empty, which would put nn first and leave no interior landmark, nor everything, which would put nn last. Hence 2n−1−22^{n-1} - 2 permutations with one peak, and by the same argument with the smallest value, 2n−1−22^{n-1} - 2 with one valley. The two families do not overlap, so L(n)=2(2n−1−2)=2n−4.L(n) = 2\left(2^{n-1} - 2\right) = 2^n - 4.

Now ask when 2n−4=4(2n−2−1)2^n - 4 = 4\left(2^{n-2} - 1\right) is a perfect square. Since 44 is already a square, the question is exactly whether 2n−2−12^{n-2} - 1 is one. For n=3n = 3 it equals 1=121 = 1^2, so L(3)=4=22L(3) = 4 = 2^2 and n=3n = 3 works. For n=4n = 4 it equals 33, which is not a square.

For n≥5n \geq 5, so that k=n−2≥3k = n - 2 \geq 3, look modulo 88. Since 8∣2k8 \mid 2^k, 2k−1≡−1≡7(mod8).2^k - 1 \equiv -1 \equiv 7 \pmod 8. But the squares modulo 88 are only 00, 11 and 44, since an even number squares to 00 or 44 and an odd number squares to 11. So 2k−12^k - 1 is never a square once k≥3k \geq 3, and no n≥5n \geq 5 can work.

The largest, and in fact the only, value is n=3n = 3.

Answer 3

Solution: IOQM 2024, Q24

Key idea

The coefficient of xkx^k in p(x)q(x)p(x)q(x) is ck+ck−1+ck−3c_k + c_{k-1} + c_{k-3}, so keeping every coefficient at most 11 means no two of the chosen exponents may differ by 11, 22 or 33.

Write p(x)=∑i=014cixip(x) = \sum_{i=0}^{14} c_i x^i with each ci∈{0,1}c_i \in \{0,1\} and c14=1c_{14} = 1, since the degree is exactly 1414. Because q(x)=1+x+x3q(x) = 1 + x + x^3, [xk] p(x)q(x)=ck+ck−1+ck−3,[x^k]\,p(x)q(x) = c_k + c_{k-1} + c_{k-3}, with the convention that cj=0c_j = 0 outside the range. There is no carrying anywhere: these are integer coefficients, not binary digits. So the requirement is that for every kk, ck+ck−1+ck−3≤1.c_k + c_{k-1} + c_{k-3} \le 1.

Read off what that forbids. Taking kk and k−1k-1 together says no two chosen exponents differ by 11; taking kk and k−3k-3 says none differ by 33; and taking k−1k-1 and k−3k-3, which appear in the same sum, says none differ by 22. Conversely, if no two chosen exponents differ by 11, 22 or 33, then in each sum at most one term is 11. So the condition is exactly any two exponents used by p differ by at least 4.\text{any two exponents used by } p \text{ differ by at least } 4.

Now count. The set of exponents is a subset S⊆{0,1,…,14}S \subseteq \{0, 1, \ldots, 14\} containing 1414, with all gaps at least 44. Removing 1414 leaves a subset of {0,1,…,10}\{0, 1, \ldots, 10\} with gaps at least 44, of some size jj. For example, three of the remaining exponents might be 0,4,100,4,10. Compressing the compulsory gaps moves them to 0,1,40,1,4: original exponents0410subtracted spaces036compressed exponents014\begin{array}{c|ccc} \text{original exponents}&0&4&10\\ \text{subtracted spaces}&0&3&6\\ \hline \text{compressed exponents}&0&1&4 \end{array} The compressed entries are still distinct, and adding back 0,3,60,3,6 recovers the original choice. In general such subsets are counted by subtracting 33 from the second element, 66 from the third and so on, which turns them into arbitrary jj-element subsets of a set of 11−3(j−1)11 - 3(j-1) numbers. So there are (14−3jj)\binom{14-3j}{j} of them, and (140)+(111)+(82)+(53)+(24)=1+11+28+10+0=50.\binom{14}{0} + \binom{11}{1} + \binom{8}{2} + \binom{5}{3} + \binom{2}{4} = 1 + 11 + 28 + 10 + 0 = 50.

Answer 50

Solution: IOQM 2025 Part SEP, Q7

Key idea

Comparing two neighbouring four-term averages says only xi<xi+4x_i < x_{i+4}, and comparing seven-term averages says only xi>xi+7x_i > x_{i+7}; a contradiction appears exactly when steps of +4+4 and −7-7 can be arranged into a loop that fits inside the sequence.

This loop uses eleven indices; every step is +4 or -7 .
This loop uses eleven indices; every step is +4+4 or −7-7.

Let the sequence be x1,…,xLx_1, \ldots, x_L. Two consecutive four-term averages differ by xi+⋯+xi+34<xi+1+⋯+xi+44,\frac{x_i+\cdots+x_{i+3}}{4} < \frac{x_{i+1}+\cdots+x_{i+4}}{4}, and all but the end terms cancel, so the condition is xi<xi+4for i=1,…,L−4.x_i < x_{i+4} \quad \text{for } i = 1, \ldots, L-4. The same cancellation on the seven-term averages, now decreasing, gives xi>xi+7for i=1,…,L−7.x_i > x_{i+7} \quad \text{for } i = 1, \ldots, L-7.

Draw the indices 1,…,L1, \ldots, L as dots and put an arrow from ii to jj whenever one of those requirements says xi<xjx_i < x_j. There are two kinds of arrow: from ii to i+4i+4, and from jj to j−7j-7, the second because xj−7>xjx_{j-7} > x_j reads as an arrow pointing backwards from jj to j−7j-7. Every arrow means the same thing, that the value at its head is the larger.

Now the question is whether such a picture can be filled in with real numbers, and the answer is that it can exactly when the arrows cannot be followed round into a loop. One direction is clear: following a loop all the way round would give xi<xix_i < x_i.

For the other, suppose there is no loop. Repeatedly pick a dot that no remaining arrow points to, which is always possible when there is no loop, since otherwise one could keep walking backwards along arrows for ever and would have to revisit a dot. Rub it out and carry on, listing the dots in the order chosen, then hand out the values 1,2,3,…1, 2, 3, \ldots along that list. Every arrow then runs from a smaller value to a larger one: if an arrow goes from ii to jj and ii were still on the board when jj was chosen, that arrow would be pointing at jj and jj could not have been chosen. So ii is always rubbed out first and always gets the smaller value. Hence the sequence exists.

The direction of that sweep matters. Picking a dot with no arrow leaving it and then counting upwards would put the large values at the wrong end and reverse every inequality.

Here is the observation that settles both directions at once: modulo 1111 the two moves are the same, since −7≡4(mod11)-7 \equiv 4 \pmod{11}. So every move advances the index by 44 modulo 1111, and a loop of kk moves needs 4k≡0(mod11)4k \equiv 0 \pmod{11}, hence 11∣k11 \mid k. Moreover the positions along k=11k = 11 consecutive moves occupy eleven different remainders modulo 1111, because 44 is coprime to 1111, so they are eleven different indices.

Therefore no loop can fit inside {1,…,10}\{1, \ldots, 10\}, and for L=10L = 10 the inequalities are consistent: list the indices in an order compatible with every required comparison, which is possible precisely because there is no loop, and assign increasing values along that list.

For L=11L = 11 a loop does fit, and here it is: 1→5→9→2→6→10→3→7→11→4→8→1,1 \to 5 \to 9 \to 2 \to 6 \to 10 \to 3 \to 7 \to 11 \to 4 \to 8 \to 1, seven steps of +4+4 and four of −7-7, every index between 11 and 1111. Going once round would give x1<x1x_1 < x_1. Any longer sequence contains this loop as well.

Hence the greatest possible length is 1010.

Answer 10

Report an error on this page

Reports are stored by Netlify. See the privacy note.