Given the natural number $n$,who is in the form $p^2 \cdot q^2$,with $p$,$q$ prime numbers.Also $φ(n)$ is given.Describe a fast algorithm(polynomial time) that calculates the $p$ and $q$.Apply your algorithm to calculate the $p$,$q$ when $n=34969$ and $φ(n)=29920$
I found this problem on a mathematical competition on cryptography.I tried to find a solution alone and in the internet and i didn't conclude anywhere, can we find a solution?
Hint: $$\phi(n) = n^2 - n(p+q) - pq$$