$ABC$ is right-angled at $C$. Point $P$ is on AB so that $CP$ is perpendicular to $AB$. If $BP = 31^3$ and the lengths of $AB, BC$ and $AC$ are integers, determine all possible lists of side lengths for the triangle.
As $ABC$ and $PBC$ are similar $AB : BC = BC : BP$ and thus $BC^2=AB \cdot 31^3$.
Since $AB, BC$ are integers, $AB=d^2 \cdot 31$ and $BC=d \cdot 31^2$ for some integer $d$. Then by Pythagorean Theorem
$CA^2=AB^2-BC^2=d^4 \cdot 31^2 - d^2 \cdot 31^4=d^2 \cdot 31^2(d^2-31^2)$.
Hence, $d^2-31^2$ is perfect square.
Now how do I proceed? I'm stuck here.