Consider the Diophantine equation $Ax^2+By^2=z^2$, with positive integer parameters $A$ and $B$ (not necessarily square-free or co-prime). When does this equation have a non-trivial solution? Can one give a comprehensible necessary and sufficient condition that $A$ and $B$ must satisfy?
I am aware of the Legendre theorem, but it assumes that $A$ and $B$ be co-prime and square-free; can one somehow get around this assumption?
Thanks in advance!