Library · Between the Challenge and the Olympiad · Chapter 8
Counting and Arrangements
On this page
- Problems
- Solutions
- Solution: PRMO 2013, Q4
- Solution: PRMO 2015 Part A, Q5
- Solution: IOQM 2024, Q2
- Solution: PRMO 2012, Q6
- Solution: PRMO 2013, Q5
- Solution: PRMO 2017, Q21
- Solution: PRMO 2019, Q5
- Solution: IOQM 2021 Part A, Q7
- Solution: IOQM 2025 Part SEP, Q7
- Solution: PRMO 2012, Q15
- Solution: PRMO 2017, Q9
- Solution: PRMO 2017, Q10
- Solution: PRMO 2017, Q20
- Solution: PRMO 2018, Q11
- Solution: PRMO 2018, Q12
- Solution: PRMO 2019, Q15
- Solution: PRMO 2019, Q17
- Solution: IOQM 2023, Q17
- Solution: IOQM 2024, Q14
- Solution: IOQM 2026, Q23
- Solution: PRMO 2018, Q24
- Solution: PRMO 2018, Q27
- Solution: PRMO 2018, Q28
- Solution: IOQM 2023, Q20
- Solution: IOQM 2023, Q21
- Solution: IOQM 2023, Q24
- Solution: IOQM 2026, Q22
- Solution: IOQM 2022, Q24
- Solution: IOQM 2023, Q22
- Solution: IOQM 2025 Part SEP, Q28
Problems
Problem 1
Three points are on a straight line such that and . What is the product of all possible values of ?
Problem 2
How many line segments have both their endpoints located at the vertices of a given cube?
Problem 3
The number of four-digit odd numbers having digits , each occurring exactly once, is:
Problem 4
A postman has to deliver five letters to five different houses. Mischievously, he posts one letter through each door without looking to see if it is the correct address. In how many different ways could he do this so that exactly two of the five houses receive the correct letters?
Problem 5
There are red balls, green balls and blue balls in a bag. The number of ways of choosing two balls from the bag that have different colours is . What is the value of ?
Problem 6
Find the number of ordered triples of positive integers such that .
Problem 7
Five persons wearing badges with numbers are seated on chairs around a circular table. In how many ways can they be seated so that no two persons whose badges have consecutive numbers are seated next to each other? (Two arrangements obtained by rotation around the table are considered different.)
Problem 8
Find the number of maps such that whenever .
Problem 9
How many isosceles integer-sided triangles are there with perimeter ?
Problem 10
How many non-negative integral values of satisfy the equation ? (Here denotes the greatest integer less than or equal to . For example and .)
Problem 11
There are five cities on a certain island. Each city is connected to every other city by road. In how many ways can a person starting from city come back to after visiting some cities without visiting a city more than once and without taking the same road more than once? (The order in which he visits the cities also matters: e.g., the routes and are different.)
Problem 12
There are eight rooms on the first floor of a hotel, with four rooms on each side of the corridor, symmetrically situated (that is each room is exactly opposite to one other room). Four guests have to be accommodated in four of the eight rooms (that is, one in each) such that no two guests are in adjacent rooms or in opposite rooms. In how many ways can the guests be accommodated?
Problem 13
What is the number of triples of positive integers such that (i) and (ii) form the sides of a quadrilateral?
Problem 14
There are several tea cups in the kitchen, some with handles and the others without handles. The number of ways of selecting two cups without a handle and three with a handle is exactly 1200. What is the maximum possible number of cups in the kitchen?
Problem 15
Determine the number of -tuples such that and is a multiple of .
Problem 16
In how many ways can a pair of parallel diagonals of a regular polygon of sides be selected?
Problem 17
Find the number of ordered triples of positive integers such that .
Problem 18
Consider the set where are integers. If is the average value of the fourth element of such a tuple in the set, taken over all the elements of , find the largest integer less than or equal to .
Problem 19
Initially, there are particles at the origin . At each step the particles are moved to points above the -axis as follows: if there are particles at any point , then of them are moved to , are moved to and the remaining to . For example, after the first step, there are particles each at , and . After the second step, there are particles each at and , particles each at and , and particles at . After steps, the number of particles at is:
Problem 20
A rectangle is divided into five squares by drawing four line segments parallel to the shorter side of the rectangle. Each of the resulting sixteen unit-length line segments is coloured red, blue or green. A square is called colourful if all the three colours are used in colouring its sides. If is the number of ways of colouring such that all the five squares are colourful, find the remainder when is divided by .
Problem 21
If is the number of triangles of different shapes (i.e., not similar) whose angles are all integers (in degrees), what is ?
Problem 22
What is the number of ways in which one can colour the squares of a chessboard with colours red and blue such that each row as well as each column has exactly two red squares and two blue squares?
Problem 23
Let be the number of ways of distributing 8 chocolates of different brands among 3 children such that each child gets at least one chocolate, and no two children get the same number of chocolates. Find the sum of the digits of .
Problem 24
For any finite non empty set of integers, let denote the largest element of and denote the number of elements in . If is the number of ordered pairs of finite non-empty sets of positive integers, such that and can be written as where are positive integers less than 100, find .
Problem 25
For , consider non-negative integer-valued functions on satisfying for and . Choose such that is the least. How many such functions exist in that case?
Problem 26
A trapezium in the plane is a quadrilateral in which a pair of opposite sides are parallel. A trapezium is said to be non-degenerate if it has positive area. Find the number of mutually non-congruent, non-degenerate trapeziums whose sides are four distinct integers from the set .
Problem 27
Let be the number of distinct -digit numbers obtained by arranging the six numbers , where the first digit of the digit number is not zero. Find the sum of the digits of .
Problem 28
Let be the number of ways of distributing 52 identical balls into 4 distinguishable boxes such that no box is empty and the difference between the number of balls in any two of the boxes is not a multiple of 6. If , where are positive integers less than 100, find .
Problem 29
In an equilateral triangle of side length 6, pegs are placed at the vertices and also evenly along each side at a distance of 1 from each other. Four distinct pegs are chosen from the 15 interior pegs on the sides (that is, the chosen ones are not vertices of the triangle) and each peg is joined to the respective opposite vertex by a line segment. If denotes the number of ways we can choose the pegs such that the drawn line segments divide the interior of the triangle into exactly nine regions, find the sum of the squares of the digits of .
Problem 30
There are 10 members in a delegation. No two of them have the same height. Let be the number of ways in which they can stand in a line for a photograph such that
the leftmost person is the shortest,
the rightmost person is the tallest, and
in the line between the shortest and tallest person, there is exactly one person who is shorter than both of his immediate neighbours.
If can be written as where and are positive integers less than 100, find .
Solutions
Solution: PRMO 2013, Q4
may sit on either side of , giving or .
Put at the origin of a number line and at . The point is at distance from , so it is at or at , and correspondingly Both are genuinely possible, since nothing in the question orders the three points. The product is
Answer 91
Solution: PRMO 2015 Part A, Q5
A segment is decided entirely by its two endpoints, so the count is a choice of two vertices from eight and nothing more.
A cube has vertices, and a line segment with both endpoints at vertices is determined by which pair of vertices it joins. Different pairs give different segments, and every pair gives one. So the number of segments is
Students sometimes hesitate here, wondering whether the twelve edges, the face diagonals and the space diagonals should be counted separately and added. They can be, and it is a useful check: edges, diagonals on each of faces giving , and space diagonals, for a total of . The two routes agree, which is what one wants from a counting problem.
Answer 28
Solution: IOQM 2024, Q2
The last digit has to be odd, and once it is chosen the remaining three digits may be arranged freely.
The number uses each of exactly once, and it is odd precisely when its last digit is or . That is choices. The other three digits then occupy the first three places in any order, which can be done in ways.
So the count is .
Answer 12
Solution: PRMO 2012, Q6
Choose which two houses are right, then send the other three letters all to wrong houses.
Choosing the two correctly delivered letters can be done in ways. The remaining three letters must go to the remaining three houses with none of them correct, and there are exactly two ways to do that. Label those houses , with each letter named for its proper house. If letter goes to , letter must go to and letter to . If letter goes to , the other direction is forced:
So the number of ways is
Note that “exactly two” is what makes this finite and small: had the question said “at least two”, the count would run over the other cases too.
Answer 20
Solution: PRMO 2013, Q5
The three cross terms add to , so the equation is .
A pair of different colours is one red and one green, or one green and one blue, or one blue and one red. With red, green and blue balls, which is . The two linear terms cancel, which is the tidy part of the arrangement.
Setting gives and
Answer 10
Solution: PRMO 2017, Q21
Each prime is distributed independently, so the count is a product of stars-and-bars factors, one for the two s and one for the three s.
Since , giving an ordered triple with means deciding how many of the two factors of go to each of , , , and likewise for the three factors of . The two decisions are independent.
For example, allocating the two factors of as one to , one to and none to can be shown by two stars separated into three groups: Placing the two bars among the four star-or-bar positions gives the six possible allocations, including empty groups. Distributing identical items into labelled boxes can be done in ways, and identical items in ways. Hence
Answer 60
Solution: PRMO 2019, Q5
Three of the five people have only two possible neighbours each, so their edges are forced, and the forced edges already close up into a single cycle.
Think of the seating as a cycle on the five badges, where two badges are joined when they sit next to each other. The rule forbids joining to , to , to and to , so the permitted neighbours are
Badges , and have exactly two permitted neighbours each, and in the seating every person has exactly two neighbours. So all of those pairings are forced: must sit between and , badge between and , and badge between and . Collecting them, the five adjacencies must be which is precisely the single cycle . There is exactly one admissible cyclic order.
Now count seatings. Rotations are counted as different, so the cycle can be placed on the five chairs in rotations, and it can be traversed in either of directions, giving seatings in all.
Answer 10
Solution: IOQM 2021 Part A, Q7
A non-decreasing map is determined by which three values it takes, repeats allowed and order irrelevant, so this is a question about choosing with repetition rather than about functions at all.
The condition whenever says that . Once we know which three values are used, and with what multiplicity, the map is completely determined, because the values must be written in increasing order. So counting maps is the same as counting the ways of choosing three values from five with repeats allowed and order ignored.
The standard count for that is with and , which comes from the stars-and-bars correspondence: lay out three stars and four bars, and read off how many of each value to take. For example, The five groups contain stars: those are the numbers of copies of the values . Here
Answer 35
Solution: IOQM 2025 Part SEP, Q7
Write the triangle as with ; the triangle inequality traps between two bounds and every value in between works.
Let the equal sides be and the third side , so with positive integers. The only triangle inequality that can fail is , that is At the other end, forces , so .
Every from to gives a genuine triangle, and different values of give non-congruent triangles, so there are of them. (No equilateral triangle appears, since is not divisible by , so nothing is counted twice.)
Answer 6
Solution: PRMO 2012, Q15
If both floors equal then lies in and in , and those overlap only for .
Let be the common value of the two floors. Then For an overlap we need , that is , so only three values of are possible.
Taking them in turn:
: , five values.
: , three values.
: , one value.
So there are non-negative integers in all.
Answer 9
Solution: PRMO 2017, Q9
A route is a cycle through , so it is decided by which other cities are used and in what order, giving for each length.
A route leaves , passes through some of the other four cities without repetition, and returns. Since every pair of cities is joined, the only decisions are which cities to use and in what order. A route through other cities is therefore determined by an ordered selection of cities out of four, and each such selection gives exactly one route.
How small can be? Not , and not : going would use the road twice. So runs from to , and
The problem’s remark that the two directions count separately is exactly what makes this an ordered count, and it is why each cycle contributes rather than .
Answer 60
Solution: PRMO 2017, Q10
Each opposite pair may hold at most one guest, so with four guests every pair holds exactly one, and the side must alternate along the corridor.
Number the rooms on one side and on the other, with opposite . Forbidden pairs are with , and consecutive rooms on the same side.
Each of the four opposite pairs can hold at most one guest, and there are four guests, so every pair holds exactly one. Reading along the corridor, that means a choice for each of which side its guest is on.
Now the adjacency rule bites. If the guests in positions and were on the same side they would be in adjacent rooms, so consecutive choices must alternate. There are exactly two alternating patterns for four positions, namely
Finally the guests are four different people, so each set of rooms can be filled in ways:
Answer 48
Solution: PRMO 2017, Q20
Four lengths form a quadrilateral exactly when the longest is less than the sum of the other three, and here the longest is , so the count is of triples with .
Four positive lengths are the sides of a quadrilateral exactly when each is less than the sum of the other three. Here is the needed converse in this case. Draw a diagonal of length , and build triangles with sides and on its opposite sides. Both are non-degenerate precisely when These intervals overlap exactly when : the other lower bound is already below , and exceeds both lower bounds and . Joining the two triangles then gives a quadrilateral with the required sides. Since , the side of length is the longest, so the only condition that can fail is
There are triples with , so count instead the failures, those with : and nothing else, since already needs and gives . That is failures, so the count is
Answer 73
Solution: PRMO 2018, Q11
The equation is , and running through the few values of that divide leaves three solutions, of which the largest total is .
Let be the number of cups without handles and the number with. The selections are independent, so
Go through the values of in turn, keeping only those that divide and leave a quotient of the form : The values for are , and , none of which divides ; and for we have , which would force , that is , which would need to be , or . None of the three is a binomial coefficient of that shape, as the neighbouring values show:
So the kitchen holds , or , or cups, and the maximum is
A word about the key. The official answer cell for this question reads “”, because the phrase maximum possible was dropped in translation and all three totals were given full credit. The English paper does ask for the maximum, and its answer is .
Answer 29
Solution: PRMO 2018, Q12
Modulo the coefficients repeat as , so the two multiples of are free and what remains is a comparison of two sums of three signs.
Reduce the coefficients modulo . The terms with and vanish, whatever their signs, so and are free: choices. What is left is all of it modulo , since and .
Write for the first bracket and for the second. Each is a sum of three signs, so it takes the values in ways respectively. Modulo those values are , so and the same for . The condition is , so the number of choices for the six constrained signs is
Multiplying by the free choices,
Answer 88
Solution: PRMO 2019, Q15
Two chords of a regular -gon are parallel exactly when the sum of their endpoint labels is the same modulo , which sorts all diagonals into ten families and turns the count into two binomial coefficients.
Label the vertices around the circle, with at angle . The chord is perpendicular to the radius bisecting its arc, so its direction, taken modulo , is Two chords are therefore parallel exactly when , that is when
So sort the chords by the value of modulo , giving ten families of mutually parallel chords. How big is each family? Fix a remainder and count the pairs with and . There are ten ordered pairs with , one for each . If is even, two of them have , namely and , leaving ordered pairs and hence chords. If is odd, none has , leaving chords. The tally checks out: .
Sides must now be removed, since the question asks about diagonals. The side has , always odd, so every side lies in an odd family. How many in each? Fixing an odd and asking for means , and since is even this has exactly two solutions modulo , namely and . So each odd family contains exactly two sides, accounting for all ten, and the even families contain none. Hence
each of the five odd families has diagonals,
each of the five even families has diagonals,
for a total of diagonals, as it should be.
A pair of parallel diagonals is a pair chosen from one family, so the answer is
The even families are the larger ones because a chord in an even family never touches the two vertices and that anchor it, while an odd family gets to use all ten vertices. It is the same parity distinction that makes a regular polygon with an even number of sides have diameters at all.
Answer 45
Solution: PRMO 2019, Q17
Dividing by makes the bound , and subtracting the compulsory from each variable turns it into a small non-negative count that a three-line case split finishes.
Every term on the left of is a multiple of , so the left-hand side is a multiple of and the bound may be sharpened to , that is Since , write , , with . The condition becomes
Now count, splitting on , which can only be , or since .
leaves , and allow respectively: .
leaves , and allow : .
leaves , and allow : .
Adding, ordered triples.
Answer 30
Solution: IOQM 2023, Q17
Describe a tuple by the six gaps it leaves in ; the six gaps are interchangeable, so each has the same average, and is four gaps plus four.
An element of is just a choice of five numbers from , written in increasing order. For a smaller example, choose from through . The unchosen numbers before, between and after the chosen ones form six gaps of sizes :
Record the actual choice from through by its gaps: These six numbers are non-negative and Conversely every such six-tuple of non-negative integers summing to comes from exactly one element of , so the correspondence pairs the two collections off exactly.
Here is the point of setting it up this way. The description is completely symmetric in the six gaps: permuting them gives another valid six-tuple. So when we average over all of , the six gaps have the same average value, and since they sum to that common average is .
Now express the fourth element in terms of gaps. Unwinding the definitions, Taking averages and using the common value, The largest integer not exceeding is therefore .
Nothing in the argument used the number except at the last step, so the same reasoning gives the average of the th element as , which is the familiar rule that the chosen points sit, on average, evenly spread.
Answer 66
Solution: IOQM 2024, Q14
Reaching in steps leaves almost no freedom: of the steps must go right and only one can stand still, so the count is the number of ways to choose which step that is.
At every step a particle moves one unit up, and its -coordinate changes by , or . Suppose a particle takes steps to the right, straight up and to the left. After steps at the point , Subtracting the second equation from the first leaves and since and are non-negative integers the only possibility is and , so . Exactly one of the eighty steps is a straight-up step and the rest go right, and there are ways to choose which step that is.
Now count particles rather than paths. The claim is that after steps the pile at any point holds exactly particles for each path of length reaching that point, and it follows by induction on .
At there is one path, the empty one, and particles. Suppose the claim holds at step . Every pile then has size times a whole number, so it is divisible by , and the rule splits it into three exactly equal parts with the floors rounding nothing away. Each part is times the number of paths that reached the old point, and a point at step collects one such part from each of its predecessors. Adding them gives times the total number of paths reaching it, which is the claim at .
After steps a pile is therefore particle per path, and there are paths to . The answer is .
Answer 80
Solution: IOQM 2026, Q23
Whatever colour a square’s left side has, the square can be finished in exactly ways, so the count is three choices for the first vertical segment and a factor of for each of the five squares.
Colour from left to right: the leftmost vertical segment first, then for each square in turn its right side, its top and its bottom. When a square is reached its left side is already coloured, say .
Right side also : the top and bottom must be the other two colours, in either order, which is ways.
Right side one of the other colours: the third colour must appear on the top or the bottom. Of the choices for that pair, avoid it, so do not, giving ways.
That is ways whatever is, so and the remainder on division by is .
Answer 96
Solution: PRMO 2018, Q24
Ordered triples of positive integers summing to are counted by a stars-and-bars binomial, and the ordered count becomes an unordered one once the triples with a repeat are pulled out and counted separately.
A triangle up to similarity is an unordered triple of positive integers with .
Count the ordered triples first. A smaller example is , drawn as a row of units with its two dividers: The dividers occupy two of the seven gaps between units, ensuring that every part is positive. Writing as an ordered sum of three positive integers is a choice of two dividers among the gaps in a row of units, so there are of them.
Now pass to unordered triples. An ordered triple has arrangements if its three entries are distinct, if exactly two agree and if all three do, so the triples with a repeat have to be removed before dividing.
All three equal means : one shape, one ordered triple.
Exactly two equal means and with running from to , which keeps positive, and excluding , which is the all-equal case. That is shapes, each appearing as ordered triples, so ordered triples.
The rest have three distinct entries: ordered triples, which is shapes. Altogether and .
Answer 27
Solution: PRMO 2018, Q27
Each row picks a pair of columns, and the four pairs must cover every column twice, so the four pairs are either two complementary pairs each used twice, or four different pairs with the two left out forming a complementary couple.
Record each row by the pair of columns it colours red. The column condition says the four pairs, counted with multiplicity, cover each of the four columns exactly twice.
For example, these two boards satisfy the conditions; marks a red square and a blue one: The first uses row-pairs and the second uses . There are six pairs in all, and they fall into three complementary couples: , , , where the two pairs of a couple are disjoint.
Case 1: a repeated pair
Suppose some pair is used twice. It covers its two columns twice already, so the other two rows must cover only the complementary pair , hence both are . The four pairs are for one of the three couples, and the four rows can be arranged in orders. That is colourings.
Case 2: four distinct pairs
Now the four pairs are distinct, so exactly two of the six are unused. Each column lies in three of the six pairs and must be covered twice, so each column lies in exactly one unused pair. That makes the two unused pairs disjoint, that is a complementary couple: choices. The four remaining pairs can be assigned to rows in ways, giving colourings.
Total
No other shape is possible: three copies of one pair would cover its columns three times. So
Answer 90
Solution: PRMO 2018, Q28
Only two ways to write as three different positive numbers, and for each the chocolates are shared out by a factorial ratio and the sizes assigned to children in ways.
The three children get distinct positive numbers of chocolates summing to . Listing the ways of writing as a sum of three different positive numbers: and nothing else. If the smallest share were or more, the three shares would total at least ; so the smallest is , and the other two are different numbers above adding to , which leaves only and .
For each such split, the chocolates are distinguishable, so the number of ways to put them into labelled groups of sizes , and is , and the three sizes can be attached to the three children in ways because they are all different:
Hence , and its digits sum to
Answer 24
Solution: IOQM 2023, Q20
The second equation involves the prime , so and are and in one order, and each of the two cases reduces to counting subsets of a fixed size containing a fixed largest element.
Since is prime and , are positive integers, either and , or and . Take them in turn.
Case , . Write , so and the first equation reads . Thus is a divisor of and . The set consists of positive integers with largest element , so contains together with of the ten numbers , which can be done in ways. Running through the divisors: The case contributes nothing, since would need twelve elements from a pool of eleven. The total here is .
Case , . Then and , so the first equation gives . So contains together with ten of the eleven numbers , which can be done in ways.
Hence . Writing with below gives and , so .
Answer 43
Solution: IOQM 2023, Q21
Since , making the sum least means making as large as the constraint allows, and then the functions to be counted are just the ways of writing what is left over as a sum.
The condition for says that is non-decreasing. Summing the given equation, which must be non-negative since the values of are non-negative. So the sum to be minimised decreases as grows, and we want the largest with . Since the choice is , and then .
What remains is to count the non-decreasing sequences of integers with total . Reading such a sequence from the right and discarding the zeros gives a way of writing as a sum of at most positive integers in non-increasing order, and the correspondence goes both ways because is more than , so no such sum is too long to fit. Those sums are fifteen in all. So there are such functions.
Answer 15
Solution: IOQM 2023, Q24
A trapezium with parallel sides and legs exists exactly when the triangle with sides , , does, and since all four lengths lie between and this reduces to the single condition .
Slide one leg along the parallel sides: cutting off a parallelogram from the trapezium leaves a triangle with sides , and . So a non-degenerate trapezium with parallel sides and legs exists precisely when and it is then determined up to congruence. The reason is that the construction reverses: the triangle on sides , , is fixed up to congruence by its three sides, and gluing a parallelogram with sides and onto it along the side of length rebuilds the trapezium, with no freedom left. Swapping the two legs merely produces the mirror image.
The right-hand inequality never fails here. All four lengths lie in , so while . The condition is therefore just
Now count. Choose four distinct lengths from the six available, in ways, and split them into two pairs, which can be done in ways. For each such split, one pair must be the parallel sides and the other the legs, and the condition says the parallel pair is the one with the larger difference. So each split contributes exactly one trapezium, unless the two pairs have equal differences, in which case it contributes none.
That leaves us counting the splits with equal differences. A split into two disjoint pairs with a common difference is a choice of two disjoint pairs from each with difference : In the first two rows the subtracted terms are the choices sharing an endpoint. The total is .
Hence the number of trapeziums is
Answer 31
Solution: IOQM 2026, Q22
Count the arrangements of the six blocks and then correct for repeats. A string arises twice only when the single sits just before the single , or the single just before the single , because then the pair can swap roles with the block.
One string can come from different block orders. For example, all four rows below produce , with brackets showing the original six blocks: The six blocks can be arranged in ways, each giving an eight-digit string. Two arrangements give the same string only through a repeated pattern. A directly after a is either the second digit of the block or the single placed right after the single , and in the second case the glued pair and the block can exchange roles without changing the string. The same is true of . So a string is made by one arrangement, or two, or four when both repeats happen.
Gluing the single to a single after it leaves five units, arrangements, and the same for before ; both at once is . Sorting the arrangements:
neither repeat: arrangements, strings;
only the repeat: arrangements, each string twice, strings;
only the repeat: likewise strings;
both: arrangements, each string four times, strings.
That is different strings.
A string starts with exactly when the single comes first. The other five blocks then follow in orders, and only the repeat can occur: arrangements give strings and the other give , so strings start with . Hence and the sum of its digits is .
Answer 21
Solution: IOQM 2022, Q24
Differences avoid multiples of six exactly when the four counts occupy four different remainders modulo six. The total then decides which two remainders are left out, and only three pairs qualify.
Two counts differ by a multiple of precisely when they agree modulo , so the condition says the four box-counts lie in four distinct remainder classes modulo . Since there are six classes, exactly two are unused, and the sum decides which.
All six remainders together sum to , while our four counts must total . So the two omitted remainders sum to , and the unordered pairs of distinct remainders summing to are Three cases, and in each the set of four remainders is determined.
Within a case, assign the four remainders to the four distinguishable boxes in ways, then count the balls. If a box must hold a count congruent to modulo and at least , write that count as where is the least positive representative, so when and otherwise, and . Summing, .
For the omitted pair the remainders are with , so and the number of non-negative solutions is . For the remainders are with , so and the count is . For the remainders are , again with and count .
Multiplying by the assignments, Writing gives and , both below , so .
Answer 81
Solution: IOQM 2023, Q22
Four cevians cut the triangle into regions plus one extra for each interior crossing, so nine regions means exactly four crossings, and that happens either when the pegs split two and two between two sides, or when three cevians happen to be concurrent.
Cevians from the same vertex meet only at that vertex, which is on the boundary; cevians from different vertices always cross inside. A family of chords cuts a convex region into pieces, the sum being over interior intersection points and being the number of chords through . To see why, draw the chords one at a time: a new chord is cut by the points where it meets earlier chords into pieces, and each piece splits one region in two, so it adds one region more than the number of new crossing points on it. A point where chords meet is met times in this way, by every chord through it except the first. With four cevians this reads , so nine regions means A simple crossing contributes and a point where three cevians meet contributes .
Suppose the four chosen pegs lie , , to a side, with . The number of crossing pairs, before worrying about concurrency, is
Distribution . The subtracted terms give , leaving crossing pairs. Three concurrent cevians would have to come from three different vertices, which is impossible here, so the count of is exact and every such choice gives nine regions. There are ways to choose the two sides and ways to choose two pegs on each, so this contributes .
Distribution . The subtracted term is , leaving crossing pairs, which gives ten regions unless three cevians are concurrent. Concurrency makes three of those pairs meet at a single point, which contributes to the sum in place of , so the sum drops from to , and that is exactly what we want. So we need choices in which three cevians, one from each vertex, are concurrent.
When three cevians pass through one point
What decides concurrency is the three ratios in which the cevians cut the opposite sides, and the relation between them can be got with nothing but areas. Suppose cevians , , meet at an interior point . Triangles and share the apex and have bases and on one line, so their areas are in the ratio ; the same is true of and . Subtracting, and the two companion statements are obtained by relabelling. Multiplying all three, every area appears once above and once below, so The converse follows at once: if the product is and the first two cevians meet at , then the line from the third vertex through cuts its side in a ratio forced to equal the third factor, so it is the third cevian. This relation, in both directions, is Ceva’s theorem.
Counting the concurrent triples
Let the cevian from meet at distance from , the cevian from meet at distance from , and the cevian from meet at distance from , with . They are concurrent exactly when The five available ratios are for . A product of three of them, with repetition allowed, equals only as giving concurrent triples.
Each such triple is completed to a set of four pegs by adding one more peg, which may be any of the four unused pegs on any of the three sides, so ways. No set of four is counted twice, because two concurrent triples inside one such set would share the two single cevians and use the two cevians from the doubled vertex, forcing those two to meet at an interior point, which they do not. This contributes .
The other distributions. leaves crossings and leaves none, and in neither can three cevians be concurrent, so both give fewer than nine regions.
Hence , and the sum of the squares of the digits is .
Answer 77
Solution: IOQM 2025 Part SEP, Q28
With the shortest at one end and the tallest at the other, exactly one dip means the line rises to a peak, falls to a valley and rises again; choosing the valley’s height and then which taller people sit before it counts everything.
Number the heights through , so the line begins with and ends with . Between consecutive people the height either rises or falls, and the first and last comparisons are both rises. Along such a word, peaks and valleys alternate and there are as many of each, so exactly one valley means exactly one peak. The line therefore rises to a peak, falls to a valley, and rises to the end.
Here is one such line, with the three runs marked: The peak is , the valley is , and every line being counted has this shape. Keep it in view while the general count is set up.
Now count. Let be the height at the valley. It cannot be or , since those two stand at the ends, so Everyone shorter than must stand in the first rising run, since the falling run bottoms out at and the final run starts at . Everyone taller than is in one of three places, and the tallest person is fixed at the very end, so the free ones are the heights , of which there are .
Let be the set of those free heights that go into the first two runs, so the rest join the final run. The set cannot be empty, since the peak lies in it, and the peak is forced to be . Every other member of may be placed either in the rising run or in the falling run, freely, and once the sets are known the order within each run is forced. So a set of size contributes lines, and using with the term removed. Writing , which runs from to ,
So , giving , and .
Answer 52