AMC 10 Step by Step

2025 AMC 10A Problem 24

P21-25~10 minPrint

Call a positive integer fair if no digit is used more than once, it has no 0s, and no digit is adjacent to two greater digits. For example, 196196 , 2323 , and 1246312463 are fair, but 15461546 , 320320 , and 3432134321 are not fair. How many fair positive integers are there?

Log in to save your progress.
Show solution without answering

Key insight

A fair number's digits climb to the largest digit, then fall. Once the digits are chosen, every digit except the largest just picks the left or right side.

Solution

Step 1: understand the rule.

  1. A fair number uses digits from 11 to 99, each at most once. The third rule says no digit may sit in a "valley", with a bigger digit on both sides. A digit at either end has only one neighbour, so an end digit is never a problem.

2. Try a small case to see the pattern. With the digits 1,2,31, 2, 3 there are six orders:
- 123123, 132132, 231231, 321321 are fair;
- 213213 and 312312 are not, because the 11 sits between two bigger digits.

In every fair one, the digits climb up to 33 (the largest) and then go down.

Step 2: fair means "up, then down".

  1. If the digits climb to the largest digit and then fall, there is no valley. Every digit before the top has a smaller digit on its left, every digit after the top has a smaller digit on its right, and the top digit is bigger than both of its neighbours.
  1. If the digits ever go down and then later go up again, there is a valley. Follow the digits from where they start going down to where they first turn back up. The digit at that turning point has a bigger digit on its left (the digits were going down) and a bigger digit on its right (they go up again). For example, in 15461546 the digits go down from 55 to 44 and then up to 66, and 44 is the valley.
  1. So a number is fair exactly when its digits climb to the largest digit and then fall.

Step 3: count the orders of a fixed set of digits.

  1. Pick a set of kk different digits. The largest one has to sit at the top. Each of the other k−1k - 1 digits goes either on the left (climbing) side or on the right (falling) side.
  2. Once each digit has picked its side, the order is forced: the left side must be in increasing order and the right side in decreasing order.
  3. Each of the k−1k - 1 digits has 22 choices, so a set of kk digits gives 2k−12^{k-1} fair numbers. Check with {1,2,3}\{1, 2, 3\}: 22=42^2 = 4, matching the four fair numbers above.

Step 4: add up over all digit sets.

  1. The number of ways to choose kk digits out of 99 is (9k)\binom{9}{k}. Multiply by 2k−12^{k-1} and add:
kkways to choose the digitsordersfair numbers
1991199
23636227272
3848444336336
41261268810081008
5126126161620162016
68484323226882688
73636646423042304
89912812811521152
911256256256256
  1. The total is 9+72+336+1008+2016+2688+2304+1152+256=98419 + 72 + 336 + 1008 + 2016 + 2688 + 2304 + 1152 + 256 = 9841.

(Quick check on the k=2k = 2 row: every two-digit number with two different nonzero digits is fair, and there are 9×8=729 \times 8 = 72 of them.)

The answer is (C) 9841\boxed{\textbf{(C)}\ 9841}.

Why this works

A rule about neighbours ("no valleys") often turns out to be a rule about the overall shape ("up, then down"). Once you see the shape, counting splits into two easy steps: choose which digits to use, then count the ways to arrange them. The largest digit has no choice about where it goes, and that is why each set gives 2k−12^{k-1} and not 2k2^k.

Alternative approach

Here is a way to count everything at once. Give each digit 11 to 99 one of three labels: not used, left, or right. That is 39=196833^9 = 19683 ways to label.

  • Every labelling except "all not used" builds a fair number: write the left digits in increasing order, then the right digits in decreasing order.
  • Each fair number gets built exactly twice, because its largest digit can be labelled left or right and the number comes out the same.

So 19683=2×(number of fair numbers)+119683 = 2 \times (\text{number of fair numbers}) + 1, and the number of fair numbers is 19683−12=9841\dfrac{19683 - 1}{2} = 9841.

Concise solution

A shorter write-up, the way contest solutions are usually written. It may take a different route from the solution above.

The first two conditions say the digits form a sequence of distinct elements of {1,2,…,9}\{1,2,\ldots,9\}, so a fair number uses a subset of size kk for some 1≤k≤91 \le k \le 9, and no leading-zero worry arises. The third condition says no interior digit has both of its neighbours larger — that is, no interior digit is a local minimum. (End digits have only one neighbour, so they are never at fault.)

Step 1: the shape of a fair number. A string of distinct digits has no interior local minimum exactly when it increases up to its largest digit and then decreases.

One direction is immediate: in a string a1<a2<⋯<ap>ap+1>⋯>aka_1 < a_2 < \cdots < a_p > a_{p+1} > \cdots > a_k, every digit before the peak has a smaller digit on its left, every digit after the peak has a smaller digit on its right, and the peak is larger than both neighbours, so nothing is a local minimum.

Conversely, suppose the string is not of that shape. Then somewhere it goes down and later comes back up: there is a descent ai>ai+1a_i > a_{i+1} followed by an ascent aj<aj+1a_j < a_{j+1} with j≥i+1j \ge i+1. Take the first ascent after that descent; then ai+1>ai+2>⋯>aja_{i+1} > a_{i+2} > \cdots > a_j, so aj−1>aja_{j-1} > a_j while aj+1>aja_{j+1} > a_j, and position jj is an interior local minimum. So the number is not fair.

Step 2: count the orderings of a fixed digit set. Fix a set of kk digits. Its largest element must sit at the peak. Each of the other k−1k-1 digits is assigned to the increasing run (left of the peak) or the decreasing run (right of the peak); once the sides are chosen, the order within each run is forced, since the left run must be increasing and the right run decreasing. Different side-assignments give different strings, so there are exactly
2 k−12^{\,k-1}
fair numbers using that digit set. Sanity check with k=3k=3 and digits {1,2,3}\{1,2,3\}: the four strings are 123123, 132132, 231231, 321321, while 213213 and 312312 both have the 11 trapped between two larger digits.

Step 3: sum over all digit sets.
∑k=19(9k)2 k−1=12∑k=19(9k)2k=12(∑k=09(9k)2k⋅1 9−k−1)=39−12=19683−12=9841.\sum_{k=1}^{9}\binom{9}{k} 2^{\,k-1} = \frac12 \sum_{k=1}^{9}\binom{9}{k} 2^{k} = \frac12\left(\sum_{k=0}^{9}\binom{9}{k}2^k \cdot 1^{\,9-k} - 1\right) = \frac{3^9 - 1}{2} = \frac{19683 - 1}{2} = 9841.

(Quick checks: k=1k=1 gives 99 one-digit numbers, and k=2k=2 gives (92)⋅2=72\binom92 \cdot 2 = 72, which is every two-digit number with distinct nonzero digits, as it should be — no two-digit number can fail the adjacency rule.)

The answer is (C) 9841\boxed{\textbf{(C)}\ 9841}.

Review in the AoPS books

Similar problems

Problem © Mathematical Association of America (MAA), American Mathematics Competitions. Reproduced for non-commercial educational use. Solution and commentary are original to this site.