Let the sum of the first two digits be $n$, and the sum of the last two digits also be $n$. The value of $n$ ranges from 1 to 18. If the number of two-digit numbers whose digits sum to $n$ is $a_{n}$, then the desired number is $a_{1}^{2}+a_{2}^{2}+\ldots+a_{18}^{2}$. A two-digit number whose digits sum to $n$ consists of digits $a$ and $n-a$, where $0 \leq a \leq 9$ and $0 \leq n-a \leq 9$. Thus, $0 \leq a \leq 9$ and $n-9 \leq a \leq n$. If $n \leq 9$, there are $n+1$ options: $a$ takes values from 0 to $n$. If $9<n \leq 18$, there are $19-n$ options: $a$ takes values from $n-9$ to 9.

In the end, we get $a_{1}=2, a_{2}=3, \ldots, a_{8}=9, a_{9}=10, a_{10}=9, \ldots, a_{17}=2, a_{18}=1$.

## Answer

669 numbers.
[ Layouts and partitions ] [ Product rule $\quad]$

How many four-digit numbers (from 0001 to 9999) exist such that the sum of the first two digits equals the sum of the last two digits

#