Maths Olympiad Prep

Library / /357 of 740

, 2021

Combinatorics Difficulty 5.0 AIME Find the answer United States

Problem:
Let NN be the number of ways in which the letters in "HMMTHMMTHMMTHMMTHMMTHMMT" ("HMMT" repeated six times) can be rearranged so that each letter is adjacent to another copy of the same letter. For example, "MMMMMMTTTTTTHHHHHHHHHHHH" satisfies this property, but "HMMMMMTTTTTTHННННННННННМ" does not. Estimate NN.
An estimate of EE will earn 20min(NE,EN)4\left\lfloor 20 \min \left(\frac{N}{E}, \frac{E}{N}\right)^{4}\right\rfloor points.

A number or a short expression. Fractions can be typed as 3/2, and spacing doesn't matter.

Solution

Solution:
We first count the number of arrangements for which each block of consecutive identical letters has even size. Pair up the letters into 3 pairs of HH, 6 pairs of MM, and 3 pairs of TT, then rearrange the pairs. There are 12!6!3!3!=18480\frac{12!}{6!3!3!} = 18480 ways to do this.

In the original problem, we may estimate the number of arrangements by computing the fraction of arrangements with all even blocks. We estimate this by counting the number of ways to split the 6 HHs, 12 MMs, and 6 TTs into blocks, and collating the proportions of splittings which use all even blocks:
- We can split 6 as 66, 4+24+2, 3+33+3, and 2+42+4. Exactly 3/43 / 4 of the splittings have all even blocks.
- We can split 12 into 1212, 10+210+2, \ldots, 2+102+10, 8+2+28+2+2, 7+3+27+3+2, 6+4+26+4+2, 5+5+25+5+2, 6+3+36+3+3, 5+4+35+4+3, 6+2+2+26+2+2+2, 5+3+2+25+3+2+2, 4+4+2+24+4+2+2, 4+3+3+24+3+3+2, 3+3+3+33+3+3+3, 4+2+2+2+24+2+2+2+2, 3+3+2+2+23+3+2+2+2, 2+2+2+2+2+22+2+2+2+2+2.

Stars and bars to expand from the pairs variant gives 79000.

The following C++ code outputs the exact answer:
```
#include <bits/stdc++.h>
using namespace std;
#define IJK iii[0]][iii[1]][iii[2]
#define ijk i][j][k
#define MAX_N 100
#define S 3
#define N 6
long long dp[2][3][MAX_N][MAX_N][MAX_N];
int main()
{
dp[1][0][0][0][0] = 1;
for (int i = 0; i <= N; i++)
for (int j = 0; j <= 2*N; j++)
for (int k = 0; k <= N; k++)
for (int c = 0; c < S; c++)
for (int l = 0; l < S; l++)
{
int iii[] = { i, j, k }; iii[l]++;
dp[0][l][IJK] += (c != l || !(i + j + k)) * dp[1][c][ijk];
dp[1][l][IJK] += (c == l && i + j + k) * (dp[1][c][ijk] + dp[0][c][ijk]);
}
long long a = 0;
for (int i = 0; i < S; i++) a += dp[1]*[N][2 * N][N];
cout << a << endl;
return 0;
}
```

Want a route through all this instead of an archive? The track puts 2,000 problems in a working order, from AMC 10 level to the IMO shortlist.

Source: MathNet, licensed CC-BY-4.0. Statement reproduced verbatim; metadata (topic, difficulty) added by this project.