AMC 10 Step by Step

2018 AMC 10A Problem 18

P16-20~4 minPrint

How many nonnegative integers can be written in the form a7⋅37+a6⋅36+a5⋅35+a4⋅34+a3⋅33+a2⋅32+a1⋅31+a0⋅30,a_7\cdot3^7+a_6\cdot3^6+a_5\cdot3^5+a_4\cdot3^4+a_3\cdot3^3+a_2\cdot3^2+a_1\cdot3^1+a_0\cdot3^0, where ai∈{−1,0,1}a_i\in \{-1,0,1\} for 0≤i≤70\le i \le 7 ?

Log in to save your progress.
Show solution without answering

Key insight

Digits -1, 0, 1 with powers of 3 make every whole number from -3280 to 3280 exactly once; the nonnegative ones are 0 through 3280.

Solution

There are 88 digits, each with 33 choices, so 38=65613^8 = 6561 digit strings. We need to know which numbers they make.

1. Try a small case first. With only two digits, a1⋅3+a0a_1 \cdot 3 + a_0, the nine strings give
−4,−3,−2,−1,0,1,2,3,4.-4, -3, -2, -1, 0, 1, 2, 3, 4.
Nine strings, nine different numbers, and they fill the whole run from −4-4 to 44 with no gaps. Of these, 0,1,2,3,40, 1, 2, 3, 4 are nonnegative: 55 numbers.
2. Largest and smallest with 88 digits. The largest value uses all 11s:
1+3+9+27+81+243+729+2187=3280.1 + 3 + 9 + 27 + 81 + 243 + 729 + 2187 = 3280.
The smallest uses all −1-1s and gives −3280-3280.
3. Different strings give different numbers. Suppose two strings gave the same number. Find the lowest position where their digits differ. Subtract the two numbers: the positions below it cancel, that position leaves 11 or 22 times its power of 33, and every higher position leaves a multiple of the next power of 33. A number like 1⋅3k1 \cdot 3^k or 2⋅3k2 \cdot 3^k plus a multiple of 3k+13^{k+1} is never 00, so the two numbers were not equal after all.
4. So every number in the run is hit. From −3280-3280 to 32803280 there are 3280+1+3280=65613280 + 1 + 3280 = 6561 whole numbers. We have 65616561 strings making 65616561 different numbers, all inside that run, so every whole number from −3280-3280 to 32803280 appears exactly once.
5. Count the nonnegative ones. They are 0,1,2,…,32800, 1, 2, \dots, 3280, which is 32813281 numbers.

The answer is (D) 3281\boxed{\textbf{(D)}\ 3281}.

Why this works

This is like ordinary base 33, except the digits are −1,0,1-1, 0, 1 instead of 0,1,20, 1, 2. Just as in ordinary base 33, each string names a different number. Switching the sign of every digit switches the sign of the number, so the values are balanced around 00: equal numbers of positive and negative values, plus 00 once. That gives 6561+12=3281\dfrac{6561 + 1}{2} = 3281.

Alternative approach

Build the pattern from small cases. One digit gives −1,0,1-1, 0, 1: 22 nonnegative. Two digits give −4-4 to 44: 55 nonnegative. Three digits give −13-13 to 1313: 1414 nonnegative. Each count is 3k+12\dfrac{3^k + 1}{2} for kk digits (3+12\tfrac{3+1}{2}, 9+12\tfrac{9+1}{2}, 27+12\tfrac{27+1}{2}), so 88 digits give 6561+12=3281\dfrac{6561 + 1}{2} = 3281.

Concise solution

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

There are 38=65613^8 = 6561 choices of the digit string (a7,…,a0)(a_7, \dots, a_0). Two facts settle the count.

All 65616561 sums are distinct. Suppose two different strings gave the same value. Subtracting, we get ∑(ai−bi)3i=0\sum (a_i - b_i) 3^i = 0 with each ai−bi∈{−2,−1,0,1,2}a_i - b_i \in \{-2, -1, 0, 1, 2\} and not all zero. Look at the smallest index kk with ak≠bka_k \ne b_k: every other nonzero term is a multiple of 3k+13^{k+1}, while (ak−bk)3k(a_k - b_k)3^k is not, so the total cannot be 00. Contradiction.

The values are symmetric about 00. Negating every digit negates the sum, so the set of attainable values is closed under x↦−xx \mapsto -x. The largest value is 1+3+⋯+37=38−12=32801 + 3 + \dots + 3^7 = \dfrac{3^8 - 1}{2} = 3280, so the 65616561 distinct values are exactly −3280,−3279,…,3279,3280-3280, -3279, \dots, 3279, 3280 (that is 65616561 consecutive integers, so nothing is skipped).

The nonnegative ones are 0,1,…,32800, 1, \dots, 3280: that is 32813281 integers.

The answer is (D) 3281\boxed{\textbf{(D)}\ 3281}.

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.