Problem: Let $k$ be a positive integer. Bernardo and Silvia take turns writing and erasing numbers on a blackboard as follows: Bernardo starts by writing the smallest perfect square with $k+1$ digits. Every time Bernardo writes a number, Silvia erases the last $k$ digits of it. Bernardo then writes the next perfect square, Silvia erases the last $k$ digits of it, and this process continues until the last two numbers that remain on the board differ by at least 2. Let $f(k)$ be the smallest positive integer not written on the board. For example, if $k = 1$ , then the numbers that Bernardo writes are $16, 25, 36, 49, 64$ , and the numbers showing on the board after Silvia erases are $1, 2, 3, 4,$ and $6$ , and thus $f(1) = 5$ . What is the sum of the digits of $f(2) + f(4)+ f(6) + \dots + f(2016)$
$\textbf{(A)}\ 7986\qquad\textbf{(B)}\ 8002\qquad\textbf{(C)}\ 8030\qquad\textbf{(D)}\ 8048\qquad\textbf{(E)}\ 8064$

Solution: We assume $n \geq 1$ for all claims.
We will let $g_k(x) = \left \lfloor \frac{x^2}{10^k}\right \rfloor$ . This is the result when the last k digits are truncated off $x^2$
Let $x_n$ = the smallest a, such that $g_{2n}(a) - g_{2n}(a-1) \geq 2$
We then have $\left \lfloor \frac{a^2}{10^{2n}} \right \rfloor - \left \lfloor \frac{(a-1)^2}{10^{2n}} \right \rfloor \geq 2$
Claim 1: $x_n > 5\cdot10^{2n-1}$
Proof of Claim 1:
Assume for the sake of contradiction, we have $x_n \leq 5 \cdot 10^{2n-1}$
Let $c = \frac{2x_n - 1}{10^{2n}}$ $d = \frac{(x_n-1)^2}{10^{2n}}$
Note that since $x_n \leq 5 \cdot 10^{2n-1}$ , we have $c < 1$
It is well known that $\lfloor i+j \rfloor \leq \lfloor i \rfloor + \lfloor j \rfloor + 1$ for any $i$ and $j$
Since $x_n$ satisfies the condition, we have:
$1 = \lfloor c \rfloor + 1 \geq  \lfloor{c+d} \rfloor - \lfloor d \rfloor \geq 2$
This is a contradiction. $\blacksquare$
Claim 2: $x_n = 5 \cdot 10^{2n-1} + 10^n$
Proof of Claim 2:
We will show our choice of $x_n = 5 \cdot 10^{2n-1} + 10^n$ satisfies the criteria above.
$\left \lfloor \frac{{x_n}^2}{10^{2n}} \right \rfloor - \left \lfloor \frac{(x_n-1)^2}{10^{2n}} \right \rfloor = \left \lfloor \frac{25 \cdot 10^{4n - 2} + 10^{3n} + 10^{2n}}{10^{2n}} \right \rfloor - \left \lfloor \frac{25 \cdot 10^{4n - 2} + 10^{3n}   - 2 \cdot 10^n + 1}{10^{2n}} \right \rfloor$
$= (25 \cdot 10^{2n-2} + 10^{n} + 1) - (25 \cdot 10^{2n-2} + 10^{n} - 1) = 2$
Now, we will show all values smaller than $5 \cdot 10^{2n-1} + 10^n$ don’t satisfy the criteria.
We will assume for the sake of contradiction, there exists an $x'_n$ which satisfies the criteria.
We will write $x'_n$ as $5 \cdot 10^{2n - 1} + k$ . By our hypothesis, we have $k < 10^n$ . We also have $k > 0$ by claim 1.
We have $\left \lfloor \frac{{x'}_n^2}{10^{2n}} \right \rfloor -  \left \lfloor \frac{(x'_n-1)^2}{10^{2n}} \right \rfloor = \left \lfloor \frac{25 \cdot 10^{4n - 2} + k \cdot 10^{2n} + k^2}{10^{2n}} \right \rfloor - \left \lfloor \frac{25 \cdot 10^{4n - 2} + (k-1) \cdot 10^{2n} + (k-1)^2   }{10^{2n}} \right \rfloor$
$= (25 \cdot 10^{2n-2} + k) - (25 \cdot 10^{2n-2} + k - 1) = 1 \geq 2.$ This gets a contradiction. $\blacksquare$
Claim 3: $f(2n) = 25 \cdot10^{2n - 2} + 10^{n}$
Proof of Claim 3: Because of claim 2, $x_n$ is $5 \cdot 10^{2n-1} + 10^n$ . Note that $g_n(x_n)$ and $g_n(x_n - 1)$ are the first numbers written that will differ by at least 2. Thus, $f(2n) = g_n(x_n - 1) + 1 = 25 \cdot 10^{2n-2} + 10^n$ $\blacksquare$
Thus, $f(2) + f(4) \dots f(2016) = \underbrace{(2525 \dots 25)}_{1008 \ 25s} + \underbrace{(111111 \dots 1111)}_{1008 \ 1s}$ . This addition has no regroups/carry overs, so we can just take the sums of the digits of each of the addends, and sum them together to get 8064. $\boxed{8064}$

Answer: E 8064