Maths Olympiad Prep

Library / /441 of 520

Number theory Difficulty 7.4 National olympiad, round 2 Find the answer

6・113 Let the sequence a(n),n=1,2,3,a(n), n=1,2,3, \cdots, be defined as follows:
a(1)=0a(1)=0, and for n>1n>1,
a(n)=a([n2])+(1)n(n+1)2.a(n)=a\left(\left[\frac{n}{2}\right]\right)+(-1)^{\frac{n(n+1)}{2}} .
(a) Find the maximum and minimum values of a(n)a(n) for n<1996n<1996, and provide all values of nn at which these extrema are attained.
(b) For n<1996n<1996, how many terms of a(n)a(n) are equal to 0?

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

Solution

[Solution] For n>1n>1,
a(n)=a([n2])+(1)n(n+1)2,a(n)=a\left(\left[\frac{n}{2}\right]\right)+(-1)^{\frac{n(n+1)}{2}},

we can derive that for n1n \geqslant 1,
a(2n)=a(n)+(1)n(2n+1)=a(n)+(1)na(2n+1)=a(n)+(1)(2n+1)(n+1)=a(n)+(1)n+1.\begin{aligned} a(2 n) & =a(n)+(-1)^{n(2 n+1)} \\ & =a(n)+(-1)^{n} \\ a(2 n+1) & =a(n)+(-1)^{(2 n+1)(n+1)} \\ & =a(n)+(-1)^{n+1} . \end{aligned}

Assume that for n2n \geqslant 2, the binary representation of nn is
(α1α2αl)2\left(\alpha_{1} \alpha_{2} \cdots \alpha_{l}\right)_{2}

where αi=0\alpha_{i}=0 or 1,i=1,2,,l1, i=1,2, \cdots, l. Consider the l1l-1 pairs of digits
(α1,α2),(α2,α3),,(αl1,αl)\left(\alpha_{1}, \alpha_{2}\right),\left(\alpha_{2}, \alpha_{3}\right), \cdots,\left(\alpha_{l-1}, \alpha_{l}\right)

Let f(n)f(n) be the number of pairs where ak=ak+1a_{k}=a_{k+1}, and g(n)g(n) be the number of pairs where akak+1a_{k} \neq a_{k+1}, for k=1,2,,l1k=1,2, \cdots, l-1. Clearly,
f(n)+g(n)=l1f(n)+g(n)=l-1

We will prove by induction that for n2n \geqslant 2,
a(n)=f(n)g(n)a(n)=f(n)-g(n)

In fact, a(2)=a(1)+(1)1=1a(2)=a(1)+(-1)^{1}=-1.
a(3)=a(1)+(1)2=1a(3)=a(1)+(-1)^{2}=1

Also, f(2)=0,g(2)=1,f(3)=1,g(3)=0f(2)=0, g(2)=1, f(3)=1, g(3)=0. Therefore, (1) holds for n=2,3n=2,3.

Assume that for some k3k \geqslant 3, (1) holds for 2nk2 \leqslant n \leqslant k. Consider the case when n=k+1n=k+1.
 Let k+1=(α1α2al)2,l3. Then a(k+1)=a((α1α2αl)2)=a((α1α2αl1)2)+(1)(α1α2al1)2+αl=f((α1α2αl1)2)g((α1α2αl1)2)+(1)αl1+αl\begin{array}{l} \text { Let } k+1=\left(\alpha_{1} \alpha_{2} \cdots a_{l}\right)_{2}, l \geqslant 3 \text {. Then } \\ \begin{aligned} a(k+1)= & a\left(\left(\alpha_{1} \alpha_{2} \cdots \alpha_{l}\right)_{2}\right) \\ = & a\left(\left(\alpha_{1} \alpha_{2} \cdots \alpha_{l-1}\right)_{2}\right)+(-1)^{\left(\alpha_{1} \alpha_{2} \cdots a_{l-1}\right)_{2}+\alpha_{l}} \\ = & f\left(\left(\alpha_{1} \alpha_{2} \cdots \alpha_{l-1}\right)_{2}\right)-g\left(\left(\alpha_{1} \alpha_{2} \cdots \alpha_{l-1}\right)_{2}\right) \\ & +(-1)^{\alpha_{l-1}+\alpha_{l}} \end{aligned} \end{array}

If αl1=αl\alpha_{l-1}=\alpha_{l}, then
f(k+1)=f((α1α2αl1)2)+1g(k+1)=g((α1α2αl1)2)\begin{array}{l} f(k+1)=f\left(\left(\alpha_{1} \alpha_{2} \cdots \alpha_{l-1}\right)_{2}\right)+1 \\ g(k+1)=g\left(\left(\alpha_{1} \alpha_{2} \cdots \alpha_{l-1}\right)_{2}\right) \end{array}

Thus,
a(k+1)=f((α1α2αl1)2)g((α1α2αl1)2)+1=f(k+1)g(k+1).\begin{aligned} a(k+1) & =f\left(\left(\alpha_{1} \alpha_{2} \cdots \alpha_{l-1}\right)_{2}\right)-g\left(\left(\alpha_{1} \alpha_{2} \cdots \alpha_{l-1}\right)_{2}\right)+1 \\ & =f(k+1)-g(k+1) . \end{aligned}

If αl1αl\alpha_{l-1} \neq \alpha_{l}, then
f(k+1)=f((α1α2αl1)2)g(k+1)=g((α1α2αl1)2)+1\begin{array}{l} f(k+1)=f\left(\left(\alpha_{1} \alpha_{2} \cdots \alpha_{l-1}\right)_{2}\right) \\ g(k+1)=g\left(\left(\alpha_{1} \alpha_{2} \cdots \alpha_{l-1}\right)_{2}\right)+1 \end{array}

Thus,
a(k+1)=f((α1α2αl1)2)g((α1α2αl1)2)1=f(k+1)g(k+1)\begin{aligned} a(k+1) & =f\left(\left(\alpha_{1} \alpha_{2} \cdots \alpha_{l-1}\right)_{2}\right)-g\left(\left(\alpha_{1} \alpha_{2} \cdots \alpha_{l-1}\right)_{2}\right)-1 \\ & =f(k+1)-g(k+1) \end{aligned}

Therefore, (1) also holds for n=k+1n=k+1.
(a) Since (1995)10=(11111001011)2(1995)_{10}=(11111001011)_{2}, and by (1), a(n)a(n) reaches its maximum value 9 when n=(1111111111)2=1023n=(1111111111)_{2}=1023, and its minimum value -10 when n=(10101010101)2=1365n=(10101010101)_{2}=1365.
(b) Let n=(α1α2αl)2,n2n=\left(\alpha_{1} \alpha_{2} \cdots \alpha_{l}\right)_{2}, n \geqslant 2. Then a(n)=0a(n)=0 if and only if f(n)=g(n)f(n)=g(n). In this case,
l1=f(n)+g(n)=2f(n)l-1=f(n)+g(n)=2 f(n)

is even, so ll is odd.
For 2n19952 \leqslant n \leqslant 1995, ll can only be 3,5,7,9,113,5,7,9,11.
For a fixed l{3,5,7,9,11}l \in\{3,5,7,9,11\}. When 2l1n2l12^{l-1} \leqslant n \leqslant 2^{l}-1, the binary representation of nn is (α1α2αl)2\left(\alpha_{1} \alpha_{2} \cdots \alpha_{l}\right)_{2}, and α1=1\alpha_{1}=1. Therefore, a(n)=0a(n)=0 if and only if exactly l12\frac{l-1}{2} pairs (αk,αk+1)\left(\alpha_{k}, \alpha_{k+1}\right) satisfy αk=αk+1\alpha_{k}=\alpha_{k+1}. Thus, for 2l1n2l12^{l-1} \leqslant n \leqslant 2^{l}-1, there are Cl1l12C_{l-1}^{\frac{l-1}{2}} values of a(n)a(n) that are 0. Therefore, for 2n21112 \leqslant n \leqslant 2^{11}-1, the number of values of a(n)a(n) that are 0 is
C21+C42+C63+C84+C105=350 (terms). C_{2}^{1}+C_{4}^{2}+C_{6}^{3}+C_{8}^{4}+C_{10}^{5}=350 \text { (terms). }

For 1996n21111996 \leqslant n \leqslant 2^{11}-1, it is easy to see that a(n)=0a(n)=0 only for the values
(11111101010)2,(11111011010)2,(11111010110)2(11111101010)_{2},(11111011010)_{2},(11111010110)_{2},
(11111010010)2,(11111010100)2(11111010010)_{2},(11111010100)_{2}.
These 5 values.
Thus, for 2n19952 \leqslant n \leqslant 1995, there are 345 values of a(n)a(n) that are 0. Since a(1)=0a(1)=0, there are 346 values of a(n)a(n) that are 0 for n<1996n<1996.

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: NuminaMath-1.5, licensed Apache-2.0. Statement and solution reproduced as published; topic and difficulty added by this site.