JBMO TST macedonia Number Theory 
Find all $x,y$ positive integers $$x + y^2 + (\gcd(x, y))^2 = xy \cdot
 \gcd(x, y)$$

I tried supposing $\gcd(x,y)=d$ and letting $x=ad$, $y=bd$ but didn't get anything the closest thing I think is usefull that $(b+1)^2+4a^2b$ is a perfect square. 
 A: Your start is very good. Now you have $$ad+b^2d^2+d^2=abd^3$$ thus $$a+db^2+d=abd^2\implies d\mid a$$ so $a=dc$ for some integer $c$ and now we have: $$c+b^2+1=cbd^2$$
From here we have $$c={b^2+1\over bd^2-1}\implies \boxed{bd^2-1\mid b^2+1}$$
Now we have $$\color{red}{bd^2-1}\mid (b^2+1)d^2-(bd^2-1)b =\color{red}{ d^2+b }$$
From here we deduce $$bd^2-1\leq d^2+b\implies d^2\leq {b+1\over b-1}$$ 
if $b\ne 1$. Now if $b\geq 2 $ we get $d^2\leq 3$ so $d=1$ and so $$b-1\mid b^2+1 \implies b-1 \mid (b^2+1)-(b^2-1)=2$$
This means $b = 2=y$ so $a=5=x$ or   $b=3=y$ and $a=5=x$.
If $b=1$ we get from boxed relation $d-1\mid 2$ so $d=2$ or $d=3$...
A: Your substitutions give the equation
$$ad+b^2d^2+d^2=abd^3$$
Modulo $bd^2-1$ we obtain $$ad+b+d^2\equiv ad.$$ Then $bd^2-1$ is a factor of $b+d^2$ and so $bd^2-1\le b+d^2$. Either $d=1$ or $d\ge2$ and $$b\le \frac {d^2+1}{d^2-1}=1+ \frac {2}{d^2-1}<2.$$

IF $b=1.$

Then $a+2d=ad^2$. Therefore $a|2d$ and $d|a$ and so $a=d$ or $2d$. Neither possibility gives a solution.

IF $d=1,b\ge2.$

Then $b-1$ is a factor of $b+1$. Therefore $b+1\ge2(b-1)$ and $b=2$ or $3$.
The solutions are $x=5,y=2$ and $x=5,y=3.$
