problem_type: Combinatorics

exam: HMMT

problem: How many ways can the integers from -7 to 7 be arranged in a sequence such that the absolute value of the numbers in the sequence is nondecreasing?

solution_match: Answer:


solution: Each of the pairs $a,-a$ must occur in increasing order of $a$ for $a=1, \ldots, 7$, but $a$ can either occur before or after $-a$, for a total of $2^{7}=128$ possible sequences.

solution_match: Solution:


problem: Two jokers are added to a 52 card deck and the entire stack of 54 cards is shuffled randomly. What is the expected number of cards that will be between the two jokers?

solution: $52 / 3$


solution: Each card has an equal likelihood of being either on top of the jokers, in between them, or below the jokers. Thus, on average, $1 / 3$ of them will land between the two jokers.


problem: In how many ways can you rearrange the letters of "HMMTHMMT" such that the consecutive substring "HMMT" does not appear?


solution: There are $8!/(4!2!2!)=420$ ways to order the letters. If the permuted letters contain "HMMT", there are $5 \cdot 4!/ 2!=60$ ways to order the other letters, so we subtract these. However, we have subtracted "HMMTHMMT" twice, so we add it back once to obtain 361 possibilities.


solution:
A fixed point of a function $f$ is an element $a$ such that $f(a)=a$. The condition is equivalent to the property that $f$ maps every number to a fixed point. Counting by the number of fixed points of $f$, the total number of such functions is

$$
\begin{aligned}
\sum_{k=1}^{5}\binom{5}{k} k^{5-k} & =1 \cdot\left(5^{0}\right)+5 \cdot\left(1^{4}+4^{1}\right)+10 \cdot\left(2^{3}+3^{2}\right) \\
& =1+25+10 \cdot 17 \\
& =196
\end{aligned}
$$


problem:
Let $s(n)$ denote the number of 1's in the binary representation of $n$. Compute

$$
\frac{1}{255} \sum_{0 \leq n<16} 2^{n}(-1)^{s(n)}
$$


solution: Notice that if $n<8,(-1)^{s(n)}=(-1) \cdot(-1)^{s(n+8)}$ so the sum becomes $\frac{1}{255}\left(1-2^{8}\right) \sum_{0 \leq n<8} 2^{n}(-1)^{s(n)}=$ 45.


problem: How many sequences of 5 positive integers $(a, b, c, d, e)$ satisfy $a b c d e \leq a+b+c+d+e \leq 10$ ?


solution:
We count based on how many 1's the sequence contains. If $a=b=c=d=e=1$ then this gives us 1 possibility. If $a=b=c=d=1$ and $e \neq 1$, $e$ can be $2,3,4,5,6$. Each such sequence $(1,1,1,1, e)$ can be arranged in 5 different ways, for a total of $5 \cdot 5=25$ ways in this case.
If three of the numbers are 1 , the last two can be $(2,2),(3,3),(2,3),(2,4)$, or $(2,5)$. Counting ordering, this gives a total of $2 \cdot 10+3 \cdot 20=80$ possibilities.

If two of the numbers are 1 , the other three must be equal to 2 for the product to be under 10 , and this yields 10 more possibilities.
Thus there are $1+25+80+10=116$ such sequences.


problem: Paul fills in a $7 \times 7$ grid with the numbers 1 through 49 in a random arrangement. He then erases his work and does the same thing again (to obtain two different random arrangements of the numbers in the grid). What is the expected number of pairs of numbers that occur in either the same row as each other or the same column as each other in both of the two arrangements?

solution: $147 / 2$


solution:
Each of the $\binom{49}{2}$ pairs of numbers has a probability of $\frac{14 \cdot\binom{7}{2}}{\binom{49}{2}}=1 / 4$ of being in the same row or column in one of the arrangements, so the expected number that are in the same row or column in both arrangements is

$$
\binom{49}{2} \cdot(1 / 4)^{2}=\frac{147}{2}
$$


problem: There are 5 students on a team for a math competition. The math competition has 5 subject tests. Each student on the team must choose 2 distinct tests, and each test must be taken by exactly two people. In how many ways can this be done?


solution:
We can model the situation as a bipartite graph on 10 vertices, with 5 nodes representing the students and the other 5 representing the tests. We now simply want to count the number of bipartite graphs on these two sets such that there are two edges incident on each vertex.
Notice that in such a graph, we can start at any vertex and follow one of the edges eminating from it, then follow the other edge eminating from the second vertex, etc, and in this manner we must eventually end up back at the starting vertex, so the graph is partitioned into even cycles. Since each vertex has degree two, we cannot have a 2 -cycle, so we must have either a 10 -cycle or a 4 -cycle and a 6 -cycle.
In the former case, starting with Person $A$, there are 5 ways to choose one of his tests. This test can be taken by one of 4 other people, who can take one of 4 other tests, which can be taken by one of 3 other people, etc, so the number of 10 -cycles we obtain in this way is $5!\cdot 4!$. However, it does not matter which of the first person's tests we choose first in a given 10 -cycle, so we overcounted by a factor of 2 . Thus there are $5!\cdot 4!/ 2=1440$ possibilities in this case.
In the latter case, there are $\binom{5}{3}^{2}=100$ ways to choose which three people and which three tests are in the 6 -cycle. After choosing this, a similar argument to that above shows there are $2!\cdot 1!/ 2$ possible 4 -cycles and $3!\cdot 2!/ 2$ possible 6 -cycles, for a total of $100 \cdot 1 \cdot 6=600$ possibilities in this case.
Thus there are a total of 2040 ways they can take the tests.


problem: The squares of a $3 \times 3$ grid are filled with positive integers such that 1 is the label of the upperleftmost square, 2009 is the label of the lower-rightmost square, and the label of each square divides the one directly to the right of it and the one directly below it. How many such labelings are possible?


solution:
We factor 2009 as $7^{2} \cdot 41$ and place the 41 's and the 7 's in the squares separately. The number of ways to fill the grid with 1 's and 41 's so that the divisibility property is satisfied is equal to the number of nondecreasing sequences $a_{1}, a_{2}, a_{3}$ where each $a_{i} \in\{0,1,2,3\}$ and the sequence is not $0,0,0$ and not $1,1,1$ (here $a_{i}$ corresponds to the number of 41 's in the $i$ th column.) Thus there are $\binom{3+4-1}{3}-2=18$ ways to choose which squares are divisible by 41 .
To count the arrangements of divisibility by 7 and 49 , we consider three cases.
If 49 divides the middle square, then each of the squares to the right and below it are divisible 49. The two squares in the top row (besides the upper left) can be $(1,1),(1,7),(1,49),(7,7),(7,49)$, or $(49,49)$ (in terms of the highest power of 7 dividing the square). The same is true, independently, for the two blank squares on the left column, for a total of $6^{2}=36$ possibilities in this case.
If 1 is the highest power of 7 dividing the middle square, there are also 36 possibilities by a similar argument.
If 7 is the highest power of 7 dividing the middle square, there are 8 possibilities for the upper right three squares. Thus there are 64 possibilities in this case.
Thus there are a total of 136 options for the divisibility of each number by 7 and $7^{2}$, and 18 options for the divisibility of the numbers by 41 . Since each number divides 2009 , this uniquely determines the numbers, and so there are a total of $18 \cdot 136=2448$ possibilities.


problem: Given a rearrangement of the numbers from 1 to $n$, each pair of consecutive elements $a$ and $b$ of the sequence can be either increasing (if $a<b$ ) or decreasing (if $b<a$ ). How many rearrangements of the numbers from 1 to $n$ have exactly two increasing pairs of consecutive elements?

solution: $3^{n}-(n+1) \cdot 2^{n}+n(n+1) / 2$ or equivalent


solution:
Notice that each such permutation consists of 3 disjoint subsets of $\{1, \ldots, n\}$ whose union is $\{1, \ldots, n\}$, each arranged in decreasing order. For instance, if $n=6$, in the permutation 415326 (which has the two increasing pairs 15 and 26), the three sets are $\{4,1\},\{5,3,2\}$, and 6 . There are $3^{n}$ ways to choose which of the first, second, or third set each element is in. However, we have overcounted: some choices of these subsets result in permutations with 1 or 0 increasing pairs, such as $\{6,5,4\},\{3,2\},\{1\}$.
Thus, we must subtract the number of ordered partitions of $\{1,2, \ldots, n\}$ into 3 subsets for which the minimum value of the first is not less than the maximum of the second, or the minimum value of the second is not less than the maximum of the third.
We first prove that the number of permutations having exactly one increasing consecutive pair of elements is $2^{n}-(n+1)$. To do so, note that there are $2^{n}$ ways to choose which elements occur before the increasing pair, and upon choosing this set we must arrange them in decreasing order, followed by the remaining elements arranged in decreasing order. The resulting permutation will have either one increasing pair or none. There are exactly $n+1$ subsets for which the resulting permutation has none, namely, $\},\{n\},\{n, n-1\},\{n, n-1, n-2\}$, etc. Thus the total number of permutations having one increasing pair is $2^{n}-(n+1)$ as desired.
We now count the partitions of $\{1,2, \ldots, n\}$ whose associated permutation has exactly one increasing pair. For each of the $2^{n}-(n+1)$ permutations $p$ having exacly one increasing pair, there are $n+1$ partitions of $\{1,2, \ldots, n\}$ into 3 subsets whose associated permutation is $p$. This is because there are $n+1$ ways to choose the "breaking point" to split one of the subsets into two. Thus there are a total of $(n+1)\left(2^{n}-(n+1)\right)$ partitions whose associaated permutation has exactly one increasing pair.
Finally, we must count the number of partitions whose associated permutation is $n, n-1, \ldots, 3,2,1$, i.e. has no increasing pair. There are $\frac{n+2}{2}$ ways of placing two barriers between these elements to split the numbers into three subsets, and so there are $\frac{n+2}{2}$ such partitions of $\{1,2, \ldots, n\}$ into three subsets.

Thus, subtracting off the partitions we did not want to count, the answer is $3^{n}-(n+1)\left(2^{n}-(n+\right.$ 1) $)-\binom{n+2}{2}=3^{n}-(n+1) \cdot 2^{n}+n(n+1) / 2$.