TITLE: BMO2 2016 Number Theory Problem
QUESTION [11 upvotes]: Suppose that $p$ is a prime number and that there are different positive
integers $u$ and $v$ such that $p^2$ is the mean of $u^2$ and $v^2$. Prove that
$2p−u−v$ is a square or twice a square.
Can anyone find a proof. I can't really see any way to approach the problem.

REPLY [2 votes]: Note that $2p^2=u^2+v^2$, or $(p-u)(p+u)=(v-p)(v+p)$. WLOG, suppose $u<p<v$.
From the above equation, we have: 
$$2p-u-v=(p-u)+(p-v)=\frac{(v-p)(v-u)}{p+u}$$ 
Now, we do following analysis:
If $q$ is odd prime, and $q^a|(v-p)$ then $q^a\not|(v+p)$ since $p$ is prime, and $p\not|v$.
So, $q^a|(p-u)(p+u)$, and only one of $(p-u)$ and $(p+u)$ is divisible by $q^a$.
If $q^a|(p-u)$, then $q^a|(v-p+p-u)$, i.e $q^a|(v-p)$, and so $$q^{2a}|\frac{(v-p)(v-u)}{p+u}.$$
If $q^a|(p+u)$, then $$q\not|\frac{(v-p)(v-u)}{p+u}.$$ since factorization of numerator and denominator will cancel all $q$'s.
The above is true for all odd primes, so$$2p-u-v=\frac{(v-p)(v-u)}{p+u}=n^2,$$ or $$2p-u-v=\frac{(v-p)(v-u)}{p+u}=2n^2.$$