Given a binary quadratic form $Ax^2+Bxy+Cy^2$, find a neccessary and sufficient condition for an arbitrary integer $T$ to be representable by $Ax^2+Bxy+Cy^2$; i.e. the diophantine equation $Ax^2+Bxy+Cy^2=T$, have solution $x$ and $y$ in integers?
Fermat knew the answer when two squares are added together. Euler discovered many relationships and Gauss proved results for many coefficients. The question asks for a simple algorithm {using elementary mathematics} to determine $T$ (up to modulus); given $A$, $B$, $C$.
Necessary conditions are related with values of Legendre symbols, but sufficient conditions becomes more and more convoluted as $\left|B^2-4AC\right|$ becomes large. This problem is heavily related with the class number problem. An algorithmic approach due to Kaltofen and Yui is outlined in the last pages of
which is a book I strongly suggest you to read. To explain or just sketch here all the details of the quadratic forms machinery would be really time consuming, I just mention that the first chapters are dedicated to proving the classical results of Legendre, Lagrange, Euler, Fermat, Gauss et alia on quadratic forms with small discriminants, before moving to the general case.
These notes by P.L. Clarke might be helpful, too.