11.5. Let $S$ be a 100-element set consisting of natural numbers not exceeding 10000. Mark all points in space where each of the coordinates belongs to the set $S$. Attach to each of the 1000000 marked points $(x, y, z)$ a ball with the number $\frac{x^{2}+y^{2}+z^{2}}{x y+y z+z x}$ written on it. What is the maximum number of balls on which the number $2$ can be written?

(P. Kozlov)
Answer. $3 \cdot C_{100}^{2}=14850$.

Solution. Let's call a triplet of natural numbers $(x, y, z)$, whose elements belong to $S$, good if

$$
x^{2}+y^{2}+z^{2}=2(x y+y z+z x)
$$

Thus, we need to find the maximum possible number of good triplets.

Let's determine when a triplet is good. Rewrite (*) as a quadratic equation in $x$,

$$
x^{2}-2 x(y+z)+(y-z)^{2}=0
$$

Solving it, we get

$$
x=(y+z) \pm 2 \sqrt{y z}=(\sqrt{y} \pm \sqrt{z})^{2}
$$

from which $\sqrt{x}= \pm \sqrt{y} \pm \sqrt{z}$. In other words, a triplet is good if and only if one of the numbers $\sqrt{x}, \sqrt{y}$, and $\sqrt{z}$ is equal to the sum of the other two.

Let $s_{1}<s_{2}<\ldots<s_{100}$ be all the elements of the set $S$. Let $t_{i}=\sqrt{s_{i}}$. Estimate the number of good triplets $(x, y, z)$ in which $z$ is the largest number, i.e., $\sqrt{z}=\sqrt{x}+\sqrt{y}$. Note that for any $1 \leqslant i<j \leqslant 100$ there is at most one such triplet where $\sqrt{x}=t_{i}$ and $\sqrt{z}=t_{j}$ (from these values, $\sqrt{y}=\sqrt{z}-\sqrt{x}$ is restored). Therefore, the estimated number does not exceed the number of such pairs of numbers $(i, j)$, which is $C_{100}^{2}$.

Similarly, the number of good triplets in which the largest are $x$ and $y$ does not exceed $C_{100}^{2}$. Therefore, the total number of good triplets does not exceed $3 \cdot C_{100}^{2}$.

This estimate is achieved if we set $s_{i}=i^{2}$, i.e., $t_{i}=i$: indeed, then for any $i<j$ there is a good triplet $\left(s_{i}, s_{j-i}, s_{j}\right)$.

Remark 1. It can be shown that for the estimate to be achieved, it is necessary that $t_{i}=i t_{1}$ for all $i$. Since $1 \leqslant t_{i} \leqslant 100$, the example given above is unique.

Remark 2. It can be shown that the equality $\sqrt{z}=\sqrt{x}+\sqrt{y}$ for natural $x, y, z$ is possible only if the ratios $x / z$ and $y / z$ are squares of rational numbers, i.e., when $x=a^{2} t, y=b^{2} t$, and $z=c^{2} t$ for some natural $a, b, c$, and $t$ (where $a+b=c$).

This fact is not used in the solution provided above, but some students may rely on it in their work.

Comment. It is proven that a triplet is good if and only if one of the numbers $\sqrt{x}, \sqrt{y}$, and $\sqrt{z}$ is equal to the sum of the other two - 2 points (these points do not add to the points given below!).

Proving the fact mentioned in Remark 2 does not add 2 points.

If the further correct solution uses this fact without proof, 1 point is deducted.

It is proven that there are no more than 14850 good triplets - 6 points.

Only providing an example where there are exactly 14850 good triplets - 2 points.