HMMT-Feb 2016 alg, Problem 3

Let $A$ denote the set of all integers $n$ such that $1 \leq n \leq 10000$, and moreover the sum of the decimal digits of $n$ is 2. Find the sum of the squares of the elements of $A$.

Solution: From the given conditions, we want to calculate \[ \sum_{i=0}^{3} \sum_{j=i}^{3}\left(10^{i}+10^{j}\right)^{2} \] By observing the formula, we notice that each term is an exponent of 10 . $10^{6}$ shows up 7 times, $10^{5}$ shows up 2 times, $10^{4}$ shows up 9 times, $10^{3}$ shows up 4 times, $10^{2}$ shows up 9 times, 10 shows 2 times, 1 shows up 7 times. Thus the answer is 7294927 . $\fbox{7294927}$.

Answer: 7294927