TITLE: Olympiad number theory problem
QUESTION [12 upvotes]: I found this problem in previous problems of the olympiads of my country

If  $t^2+n^2=r^2$, where $t$ has $3$ positive divisors, $n$ has $30$ positive divisors and $t,n,r$ are natural numbers, find the sum of all the possible values of $t$

I did gave it a try but only solved it partially, and I really doubt this is the best way to do it.
My progress:
First, $t$ must be of the form $p^2$ where $p$ is prime
Then,  we use pythagorean triplets
Case 1:
$$t=p^2=2ab$$
$$n=a^2-b^2$$
Therfore, $p$ must be $2$, therefore $a=2, b=1$, but  this does not satisfy $n$ having $30$ divisors.
Case 2:
$$t=p^2=a^2-b^2=(a-b)(a+b)$$
$$n=2ab$$
Since $p$ is prime, we get $a=b+1$, therefore
$$p^2=2b+1$$
$$n=2(b+1)b$$
If $n$ has $30$ divisors, it must be of one of the forms
$$q^{29},r^{14}q,r^{9}q^2,r^4q^5,r^4q^2s$$
Where $r,q,s$ are different primes
Since $p$ is odd, $p^2=8k+1=2b+1$, $b=4k$ for some integer $k$
Case 2.1
$$8k(4k+1)=r^{29}\implies 4k(4k+1)=2^{28}$$
That is clearly impossible
Case 2.2
$$8k(8k+1)=r^{14}q\implies r=2$$
$$4k(4k+1)=2^{13}q$$
$$\implies 4k=2^{13} \implies q=4k+1=2^{13}+1=3×2731$$
Case 2.3
$$8k(4k+1)=r^9q^2\implies r=2$$
$$8k(4k+1)=2^9q^2$$
$$4k(4k+1)=2^8q^2$$
$$\implies 4k=2^8\implies q^2=4k+1=256+1=257$$
Case 2.4
$$8k(4k+1)=r^4q^5$$
Case 2.4.1($r=2$)
$$4k(4k+1)=2^3q^5$$
$$\implies 4k=8\implies q^5=4k+1=8+1=9$$
Case 2.4.2($q=2$)
$$4k(4k+1)=r^42^4$$
$$\implies 4k=16\implies r^4=4k+1=16+1=17$$
Case 2.5
$$8k(4k+1)=r^4q^2s\implies r=2$$
$$8k(4k+1)=16q^2s$$
$$8k(8k+2)=32q^2s$$
$$(p-1)(p+1)=32q^2s$$
$$p^2-1=32q^2s$$
Where all $p,q,s$ are odd primes
The question now is: how do I proceed from here? Was there an easier way to solve this?

REPLY [3 votes]: We add a little to the analysis by Yury. It could be that $a^2-b^2=p$, the odd leg of our triple is $p(a^2-b^2)$, and the even leg $p(2ab)$, where $(a^2-b^2,2ab,a^2+b^2)$ is a primitive triple. 
Then $2ab$ must have $15$ divisors. That leaves very few cases, since the power of $2$ that divides the even one of $a$ and $b$ must be $2^1$, $2^3$, or $2^{13}$. The odd one then must be $q^4$, $q^2$, or $1$, where $q$ is prime.  A little fooling around shows that we need $b=8$, and therefore $a=9$.
So we get the solution $t=17^2$, $n=(17)(144)$