Let $a,b,c$ be positive integers such that $a \geq b \geq c$ and $\dfrac{a-c}{2}$ is a prime. Prove that if $$a^2+b^2+c^2-2(ab+bc+ca)=b,$$ then $b$ is either a prime or a perfect square.
Proposed by Titu Andreescu.
Solution:
From the given conditions, we have $a=2p+c$, where $p$ is a prime number. Then, the given equation can be written as $$(2p-b)^2=b(4c+1).$$ Expanding $(2p-b)^2$, we see that $b|4p^2$, therefore $b \in \{1,2,4,p,2p,4p,p^2,2p^2,4p^2\}$. We have three cases.
(i) $b=2^{\alpha}$, where $\alpha \in \{0,1,2\}$. If $\alpha=0$, then $b=c=1$, but this implies $(2p-1)^2=5$, a contradiction. If $\alpha>0$, then $2^{2-\alpha}(p-2^{\alpha-1})^2=(4c+1)$. If $\alpha=1$ we have a contradiciton. If $\alpha=2$, then $(2p-1)^2=4c+1$ and since $c \in \{0,1,2,3\}$, we obtain $c=2$ and $p=2$, which gives $a=6$. Therefore, $$a=6, \qquad b=4, \qquad c=2.$$
(ii) $b=2^{\alpha}p$, where $\alpha \in \{0,1,2\}$. If $\alpha=0$, then $p=4c+1$, and for all primes of the form $4k+1$, with $k \in \mathbb{Z}^+$, we have $c=(p-1)/4$. Therefore, $$a=(9p-1)/4, \qquad b=p, \qquad c=(p-1)/4.$$ If $\alpha=1$ we get an easy contradiction, and if $\alpha=2$, we get $c=(p-1)/4$, but this implies $a=(9p-1)/4<4p=b$, contradiction.
(iii) $b=2^{\alpha}p^2$, where $\alpha \in \{0,1,2\}$. If $\alpha=0$, then $(2-p)^2=4c+1$, which gives $c=\dfrac{(p-1)(p-3)}{4}$ (note that this is an integer for all primes $p>3$) and $a=\dfrac{(p+1)(p+3)}{4}<p^2=b$ a contradiction. If $\alpha=1$ we get an easy contradiction, and if $\alpha=2$, we get $c=p(p-1)$ and $a=p(p+1)<4p^2=b$, a contradiction.
In conclusion, $b \in \{4,p\}$, hence $b$ is either a prime or a perfect square.
(i) $b=2^{\alpha}$, where $\alpha \in \{0,1,2\}$. If $\alpha=0$, then $b=c=1$, but this implies $(2p-1)^2=5$, a contradiction. If $\alpha>0$, then $2^{2-\alpha}(p-2^{\alpha-1})^2=(4c+1)$. If $\alpha=1$ we have a contradiciton. If $\alpha=2$, then $(2p-1)^2=4c+1$ and since $c \in \{0,1,2,3\}$, we obtain $c=2$ and $p=2$, which gives $a=6$. Therefore, $$a=6, \qquad b=4, \qquad c=2.$$
(ii) $b=2^{\alpha}p$, where $\alpha \in \{0,1,2\}$. If $\alpha=0$, then $p=4c+1$, and for all primes of the form $4k+1$, with $k \in \mathbb{Z}^+$, we have $c=(p-1)/4$. Therefore, $$a=(9p-1)/4, \qquad b=p, \qquad c=(p-1)/4.$$ If $\alpha=1$ we get an easy contradiction, and if $\alpha=2$, we get $c=(p-1)/4$, but this implies $a=(9p-1)/4<4p=b$, contradiction.
(iii) $b=2^{\alpha}p^2$, where $\alpha \in \{0,1,2\}$. If $\alpha=0$, then $(2-p)^2=4c+1$, which gives $c=\dfrac{(p-1)(p-3)}{4}$ (note that this is an integer for all primes $p>3$) and $a=\dfrac{(p+1)(p+3)}{4}<p^2=b$ a contradiction. If $\alpha=1$ we get an easy contradiction, and if $\alpha=2$, we get $c=p(p-1)$ and $a=p(p+1)<4p^2=b$, a contradiction.
In conclusion, $b \in \{4,p\}$, hence $b$ is either a prime or a perfect square.