8. Let $x_{i} \in\{\sqrt{2}-1, \sqrt{2}+1\}$, where $i=1,2,3, \cdots$, 2012. Define
$$
S=x_{1} x_{2}+x_{3} x_{4}+x_{5} x_{6}+\cdots+x_{2000} x_{2010}+x_{2011} x_{2012} .
$$

How many different positive integer values can $S$ attain?
8. Answer. 504
Solution. Note that $(\sqrt{2}-1)^{2}=3-2 \sqrt{2},(\sqrt{2}+1)^{2}=3+2 \sqrt{2}$ and $(\sqrt{2}-1)(\sqrt{2}+1)=1$. There are 1006 pairs of products in $S$; each pair of the product can be either $3-2 \sqrt{2}, 3+2 \sqrt{2}$ or 1 . Let $a$ be the number of these products with value $3-2 \sqrt{2}, b$ be the number of these products with value $3+2 \sqrt{2}$ and $c$ be the number of them with value 1 . The $a+b+c=1006$. Hence
$$
S=a(3-2 \sqrt{2})+b(3+2 \sqrt{2})+c=3 a+3 b+c+2 \sqrt{2}(b-a) .
$$

For $S$ to be a positive integer, $b=a$ and thus $2 a+c=1006$. Further,
$$
S=6 a+c=6 a+1006-2 a=4 a+1006 .
$$

From $2 a+c=1006$ and that $0 \leq a \leq 503$, it is clear that $S$ can have 504 different positive integer values.