AMC 10 Step by Step

2015 AMC 10A Problem 18

P16-20~5 minPrint

Hexadecimal (base-16) numbers are written using numeric digits 00 through 99 as well as the letters AA through FF to represent 1010 through 1515 . Among the first 10001000 positive integers, there are nn whose hexadecimal representation contains only numeric digits. What is the sum of the digits of nn ?

Log in to save your progress.
Show solution without answering

Key insight

In base 16, 1000 is 3E8. Every three-digit string of digits 0 to 9 starting with 0 to 3 is below it: 400 strings, minus zero.

Solution

First see how big 10001000 is in base 1616, then count the numbers written with only the digits 00 to 99.

1. Write 10001000 in base 16. The place values are 11, 1616 and 162=25616^2 = 256. Since 3×256=7683 \times 256 = 768 and 4×256=10244 \times 256 = 1024 is too big, the first digit is 33. What is left is 1000−768=232=14×16+81000 - 768 = 232 = 14 \times 16 + 8. Fourteen is the digit EE, so
1000=3E816.1000 = 3E8_{16}.
2. So every number from 11 to 10001000 has at most three base-16 digits, and a three-digit one starts with 11, 22 or 33.
3. Count the digit strings. Think of every number as three digits, with leading zeros if needed (like 0 4 70\,4\,7). We want strings that use only 00 to 99:
- first digit: 0,1,20, 1, 2 or 33 (44 choices), since 44 or more is already past 10001000;
- second digit: 00 to 99 (1010 choices);
- third digit: 00 to 99 (1010 choices).

That is 4×10×10=4004 \times 10 \times 10 = 400 strings.
4. Are they all at most 1000? The biggest one is
39916=3×256+9×16+9=921,399_{16} = 3 \times 256 + 9 \times 16 + 9 = 921,
which is less than 10001000. So yes, all of them.
5. One string is 000000, which is the number 00. It is not a positive integer, so take it away: n=400−1=399n = 400 - 1 = 399.
6. The question asks for the sum of the digits of nn: 3+9+9=213 + 9 + 9 = 21.

The answer is (E) 21\boxed{\textbf{(E)}\ 21}.

Why this works

Counting numbers with only certain digits is a multiplication count, one factor per digit place. The upper limit is the tricky part: write the limit in the same base, and check whether the biggest allowed string is under it. Here it is (921<1000921 < 1000), so no extra cases are needed. Also watch the two small details at the end: remove zero, and answer the digit sum, not nn.

Concise solution

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

First locate 10001000 in hexadecimal: 1000=3⋅256+14⋅16+81000 = 3 \cdot 256 + 14 \cdot 16 + 8, so 1000=3E8161000 = 3E8_{16}. Every integer from 11 to 10001000 has at most three hex digits, with leading digit at most 33.

Now count hex strings d2d1d0d_2 d_1 d_0 (leading zeros allowed) using only digits 00 through 99 whose value is at most 10001000. The leading digit d2d_2 must be 0,1,20, 1, 2 or 33, since 44 would give at least 4⋅256=1024>10004 \cdot 256 = 1024 > 1000. If d2≤3d_2 \le 3 and the other digits are at most 99, the largest such number is 39916=3⋅256+9⋅16+9=921<1000399_{16} = 3 \cdot 256 + 9 \cdot 16 + 9 = 921 < 1000, so every one of these strings is in range.

That gives 4⋅10⋅10=4004 \cdot 10 \cdot 10 = 400 strings, one of which is 000000, representing 00, which is not a positive integer. Hence n=399n = 399, and its digit sum is 3+9+9=213 + 9 + 9 = 21.

The answer is (E) 21\boxed{\textbf{(E)}\ 21}.

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.