BMO2 2016 Number Theory Problem 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.
 A: First assume that $p>2$ (because when $p=2$ the equation $u^2+v^2=8$ is easily solved).
Now use the following trick to form $2p-u-v$ :
$$4p^2=2\cdot 2p^2=2(u^2+v^2)=(u+v)^2+(u-v)^2$$
and use the difference of squares :
$$(2p-u-v)(2p+u+v)=(u-v)^2  $$ 
Let $q$ be a prime factor of both $2p-u-v$ and $2p+u+v$ so :
$$q \mid (2p-u-v)+(2p+u+v)=4p$$
$$q \mid (2p+u+v)-(2p-u-v)=2(u+v)$$
Now let's consider two cases :


*

*If $q$ is odd then $q \mid p$ but because $p$ is prime it follows that $q=p$ and then $p \mid u+v$ .


But then :
$$p \mid (u+v)^2-(u^2+v^2)=2uv$$
$$p \mid uv$$
If for example $p \mid u$ then also $p \mid v$ because $p \mid u+v$ .Thus both $u$ and $v$ are divisible with $p$ and so :
$$2p^2=u^2+v^2 \geq p^2+p^2=2p^2$$
Thus we must have $u=v=p$ and $2p-u-v=0$ is a perfect square .


*

*If none of the common prime factors $q$ is odd then their gcd must be a power of two , some $2^k$ 


Using the identity :
$$(2p-u-v)(2p+u+v)=(u-v)^2  $$ 
it follows that $2p-u-v=2^kx^2$ and $2p+u+v=2^ky^2$ for some $x$ and $y$ .
Thus if $k$ is even then $2p-u-v$ is a perfect square and if it's odd it's twice a perfect square which proves the claim .
A: Hint: One way to get squares from the given $2p-u-v$ is to multiply it by a conjugate, $2p+u+v$. Simplify what you get using the fact that $2p^2 = u^2+v^2$, and look at the factorization of the result. Then consider the possible values for $2p-u-v$ given that factorization.
A: 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.$$
A: Since $2p^2=u^2+v^2$, $u$ and $v$ must have the same parity and can therefore be defined as $u=x+y$ and $v=x-y$  ($x$ being the arithmetic mean of $u$ and $v$ and $y$ being half the difference between $u$ and $v$).
It follows that $2p^2=2x^2+2y^2$, which is a simple Pythagorean triple. So we can define $p=m^2+n^2$ and either $x=m^2-n^2$ and $y=2mn$ or $x=2mn$ and $y=m^2-n^2$.
In the first case, we can rewrite:
$2p-u-v=2p-x-y-x+y=2p-2x=2m²+2n²-2m²+2n²=4n²$ which is a square.
Otherwise,
$2p-u-v=2p-x-y-x+y=2p-2x=2m²+2n²-4mn=2(m-n)²$ which is twice a square.
