The question is :
Write 1009 in the form $(x^2+a\,y^2)$ for $a=1,2,3$. Where $x$ and $y$ are integers.
It is a question where we have to show our work but I know no method other than trial and error which is obviously not allowed... So please tell the correct method/trick to solve the question. Although I found answer for the first part by guess work which is: $(28)^2 + (15)^2 =1009$. But as I mentioned above we can not simply write this we have to show the work so please help.

One way is check if there is an element in $\mathbb{Z}[\sqrt D ]$ with $D$ square-free (i.e if the form $a+b\sqrt{D}$) with norm 1009.
That number $z=a+b\sqrt{D}$ must to be prime in $\mathbb{Z}[\sqrt D ]$ because divisibility of its norm.
$15^2+28^2=1009$
$19^2+2\cdot18^2=1009$
$31^2+3\cdot 4^2=1009$
$15^2+4\cdot 14^2=1009 $
$17^2+5\cdot 12^2=1009 $