AMC 10 Step by Step

2010 AMC 10A Problem 25

P21-25~10 minPrint

Jim starts with a positive integer nn and creates a sequence of numbers. Each successive number is obtained by subtracting the largest possible integer square less than or equal to the current number until zero is reached. For example, if Jim starts with n=55n = 55 , then his sequence contains 55 numbers:

5555−72=66−22=22−12=11−12=0\begin{array}{ccccc} {}&{}&{}&{}&55\\ 55&-&7^2&=&6\\ 6&-&2^2&=&2\\ 2&-&1^2&=&1\\ 1&-&1^2&=&0\\ \end{array}

Let NN be the smallest number for which Jim’s sequence has 88 numbers. What is the units digit of NN ?

Log in to save your progress.
Show solution without answering

Key insight

Work backwards. If m squared is the largest square below n, the leftover is at most 2m, so each smallest start is the previous one plus the smallest allowed square.

Solution

A sequence with 88 numbers takes 77 subtractions to reach 00. So we want the smallest number that needs 77 steps. Build the answer up from small cases.

Step 1: small cases by hand. Write "steps" for the number of subtractions.

StartSequenceSteps
111→01 \to 011
222→1→02 \to 1 \to 022
333→2→1→03 \to 2 \to 1 \to 033
777→3→2→1→07 \to 3 \to 2 \to 1 \to 044

(Numbers 44, 55, 66 go to 00, 11, 22 in one step, so they need at most 33 steps. So 77 is the smallest needing 44.)

Step 2: how big can the leftover be? Suppose the largest square not above nn is m2m^2, and the leftover is r=n−m2r = n - m^2. The next square, (m+1)2=m2+2m+1(m+1)^2 = m^2 + 2m + 1, is bigger than nn. So
r≤2m.r \le 2m.
For example, with m=2m = 2 the leftover can be at most 44 (the numbers 44 to 88).

Step 3: the rule for going one step deeper. To need one more step than some number ss, the first subtraction must leave a number that needs as many steps as ss. The smallest such start is: leftover exactly ss (the smallest leftover that works), plus the smallest square m2m^2 that is allowed, which needs 2m≥s2m \ge s.

  • 5 steps: leftover 77 needs 2m≥72m \ge 7, so m=4m = 4. Start =16+7=23= 16 + 7 = 23.
  • 6 steps: leftover 2323 needs 2m≥232m \ge 23, so m=12m = 12. Start =144+23=167= 144 + 23 = 167.
  • 7 steps: leftover 167167 needs 2m≥1672m \ge 167, so m=84m = 84. Start =842+167=7056+167=7223= 84^2 + 167 = 7056 + 167 = 7223.

Step 4: why nothing smaller works. A start with 77 steps must leave, after one subtraction, a number that needs 66 steps, so that leftover is at least 167167. Then 2m≥1672m \ge 167 forces m≥84m \ge 84, and the start is at least 842+167=722384^2 + 167 = 7223. The same reasoning checks each earlier row.

Step 5: check the sequence. 852=722585^2 = 7225 is more than 72237223, so 84284^2 really is the largest square. The sequence is
7223→167→23→7→3→2→1→0,7223 \to 167 \to 23 \to 7 \to 3 \to 2 \to 1 \to 0,
which has 88 numbers.

So N=7223N = 7223, and its units digit is 33.

The answer is (B) 3\boxed{\textbf{(B)}\ 3}.

Why this works

To find the smallest number that takes many steps, work backwards: the number after the first step must itself be the smallest one that takes one step fewer. The only limit is that the leftover can be at most twice mm, where m2m^2 is the square you subtract, which is why each answer is roughly the square of half the previous one.

Concise solution

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

Let f(n)f(n) be the number of subtractions needed to reach 00; the sequence then has f(n)+1f(n) + 1 numbers, so we want the smallest nn with f(n)=7f(n) = 7. Let sks_k denote the smallest nn with f(n)=kf(n) = k.

Write n=m2+rn = m^2 + r where m2m^2 is the largest square not exceeding nn; then 0≤r≤2m0 \le r \le 2m (otherwise (m+1)2≤n(m+1)^2 \le n), and the first step sends nn to rr, so f(n)=1+f(r)f(n) = 1 + f(r).

For f(n)=k+1f(n) = k + 1 we need f(r)=kf(r) = k, hence r≥skr \ge s_k, and then 2m≥r≥sk2m \ge r \ge s_k forces m≥⌈sk/2⌉m \ge \lceil s_k/2 \rceil. So n≥⌈sk/2⌉2+skn \ge \lceil s_k/2 \rceil^2 + s_k. This bound is attained: with m=⌈sk/2⌉m = \lceil s_k/2 \rceil and r=sk≤2mr = s_k \le 2m, the number m2+skm^2 + s_k really has m2m^2 as its largest square, and it needs exactly k+1k+1 steps. Therefore
sk+1=⌈sk2⌉2+sk.s_{k+1} = \left\lceil \tfrac{s_k}{2} \right\rceil^2 + s_k.

Starting from s1=1s_1 = 1:
s2=1+1=2,s3=1+2=3,s4=22+3=7,s5=42+7=23,s_2 = 1 + 1 = 2,\quad s_3 = 1 + 2 = 3,\quad s_4 = 2^2 + 3 = 7,\quad s_5 = 4^2 + 7 = 23,
s6=122+23=167,s7=842+167=7056+167=7223.s_6 = 12^2 + 23 = 167,\quad s_7 = 84^2 + 167 = 7056 + 167 = 7223.

(Check: 852=7225>722385^2 = 7225 > 7223, so 84284^2 is indeed the largest square, and 7223→167→23→7→3→2→1→07223 \to 167 \to 23 \to 7 \to 3 \to 2 \to 1 \to 0 is 77 steps.)

So N=7223N = 7223, whose units digit is 33.

The answer is (B) 3\boxed{\textbf{(B)}\ 3}.

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.