  By considering the norm of elements in the ring of integers in
$\mathbb{Q}(\sqrt{-a})$, we give an algebraic approach to count the number of
integral solutions of diophantine equations of the form $x^2+ay^2=n$ where $a$
is a Heegner number or $a=27$.
