Galatenko A.

A table of size 2017×2017 is filled with non-zero digits. Among the 4034 numbers, the decimal representations of which coincide with the rows and columns of this table, read from left to right and from top to bottom respectively, all except one are divisible by a prime number $p$, while the remaining number is not divisible by $p$. Find all possible values of $p$.
We will number the rows (from bottom to top) and columns (from right to left) with numbers from 0 to 2016, and denote by $a_{i, j}$ the digit at the intersection of the $i$-th row and the $j$-th column. With this numbering, the digits of the numbers in the lower positions have a smaller row (column) number.

If we denote by $v_{i}$ the number written by the digits of the $i$-th row, and by $w_{j}$ the number written by the digits of the $j$-th column, then 
\[ v_{i}=\sum_{j=0}^{2016} 10^{j} a_{i, j}, \quad w_{j}=\sum_{i=0}^{2016} 10^{i} a_{i, j}. \]

We will show that the situation described in the problem is possible for $p=2$ and $p=5$. For example, let $a_{i, j}=1$ for all $i, j \geq 1$ (these digits can be chosen as any others), $a_{0,2016}=1$, and all other digits are equal to $p$. Then all numbers read by rows and columns, except for $w_{2016}$, end in $p$ and, as a result, are divisible by $p$, while $w_{2016}$ ends in 1 and therefore is not divisible by $p$.

Now we will prove that the described situation is impossible for other $p$. Assuming the contrary, consider the quantity 
\[ S=\sum_{i, j=0}^{2016} 10^{i+j} a_{i, j}=\sum_{i=0}^{2016} 10^{i} \sum_{j=0}^{2016} 10^{j} a_{i, j}=\sum_{i=0}^{2016} v_{i}. \]

Similarly, 
\[ S=\sum_{j=0}^{2} w_{j}. \]

If all numbers $v_{i}, w_{j}(i, j=0,1,2, \ldots, 2016)$, except one, are divisible by $p$, and the remaining one is not divisible by $p$, then in one of the two last sums all terms are divisible by $p$ (which means $S$ is divisible by $p$), while in the other sum all terms, except one, are divisible by $p$, and the remaining one, due to the coprimality of $p$ and powers of ten, is not divisible by $p$. This is a contradiction.

## Answer

2 and 5.