Numbers 0 and 2013 are written at two opposite vertices of a cube. Some real numbers are to be written at the remaining 6 vertices of the cube. On each edge of the cube the difference between the numbers at its endpoints is written. When is the sum of squares of the numbers written on the edges minimal?
Answer:

$$
\left\{x_{1}, \ldots, x_{6}\right\}=\left\{\frac{2 \cdot 2013}{5}, \frac{2 \cdot 2013}{5}, \frac{2 \cdot 2013}{5}, \frac{3 \cdot 2013}{5}, \frac{3 \cdot 2013}{5}, \frac{3 \cdot 2013}{5}\right\}
$$

The function

$$
(x-a)^{2}+(x-b)^{2}+(x-c)^{2}
$$

attains its minimum when \( x = \frac{a+b+c}{3} \). Let's call the vertices of the cube adjacent if they are connected with an edge. If \( S \) is minimal, then the numbers \( x_{1}, \ldots, x_{6} \) are such that any of them is the arithmetic mean of the numbers written on adjacent vertices (otherwise, \( S \) can be made smaller). This gives us 6 equalities:

$$
\left\{\begin{array}{l}
x_{1}=\frac{x_{4}+x_{5}}{3} \\
x_{2}=\frac{x_{4}+x_{6}}{3} \\
x_{3}=\frac{x_{5}+x_{6}}{3} \\
x_{4}=\frac{x_{1}+x_{2}+2013}{3} \\
x_{5}=\frac{x_{1}+x_{3}+2013}{3} \\
x_{6}=\frac{x_{2}+x_{3}+2013}{3}
\end{array}\right.
$$

Here \( x_{1}, x_{2}, x_{3} \) are written on vertices that are adjacent to the vertex that contains 0. By solving this system we get the answer.
![](https://cdn.mathpix.com/cropped/2024_11_22_4ffd808d57e3e21b28deg-05.jpg?height=506&width=515&top_left_y=441&top_left_x=776)