The Representation of a number by a (fixed given) binary quadratic form 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$.
 A: 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

D.H. Cox - Primes of the form $x^2+ny^2$

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.
A: I am going to post my approach but I do not know whether it is correct.
Here we go:
Proposition:
Let $ A=(PM-pm);  B=[(PN+QM)-(pn+qm)]; C=(QN-qn).$ 
Then $ T=\frac{(M+N-m-n)c_1+(P+Q-p+q)}{m+n}$ ;  $m+n=+1  $;  $Pq-pQ=1;  ..c_1 $..is a free variable 
Proof:
$Write$ $ Ax^2+Bxy+Cy^2 - T= GH-JK=0 ...........    (1)$   where 
$   G=(Px+Qy+c_1)..................(2)$
$   H=(Mx+Ny+c_2).................(3)$
$   J=(px+qy+c_3)....................(4)  $
$   K=(mx+ny+c_4)...................(5) $
Now we expand the expression $GH-JK=0$ first; but it is also equal to $ Ax^2+Bxy+Cy^2-T=0 $
$(Px+Qy+c_1)(Mx+Ny+c_2)-(px+qy+c_3)(mx+ny+c_4)=0.......(6) $
So we expand the above expression in terms of powers  x and y and equate coefficients.
$ (PM-pm)x^2=Ax^2..........(7) ....A=(PM-pm) $
$ [(PN+QM)-(pn+qm)]xy=Bxy..(8) ....B= [(PN+QM)-(pn+qm)]$
$ (QN-qn)y^2=Cy^2..........(9).....C= (QN-qn)$
$[(Qc_2+Nc_1)-(qc_4+nc_3)]y=Dy=0y....(10)$
$[(Pc_2+Mc_1)-(pc_4+mc_3)]x=Ex=0x.....(11)$
$c_1c_2-c_3c_4=-T......(12)$
We add (10) and (11) together noting that the sum is zero;
$[([P+Q]c_2+[M+N]c_1)+([p+q]c_4+[m+n]c_3)]=0x+0y=0........(13)$
$[{(P+Q)-(p+q)}-{(M+N)c_1+(m+n)c_3}]=0..........(14)$
$ ... Put.. c_2=c_4=1;c_1-c_3=-T.............(14a)$  Replace in (14)
$[{(P+Q)-(p+q)}-{(M+N)c_1-(m+n)(c_1+T)}]=0..........(15)$
$[{(P+Q)-(p+q)}-{(M+N)c_1-(m+n)c_1}]=(m+n)T..........(16)$
This is the equation we obtain in the proposition.
Then $ T=\frac{(M+N-m-n)c_1+(P+Q-p+q)}{m+n}$ ;  $m+n=+1  $;  $Pq-pQ=1;  ..c_1 $..is a free variable
The coefficients of x and y are zero; so we use this fact to get T in terms of c1.
We make the choice that c2=c4=1 and c1-c3=-T. Note that (m+n)=1 or -1, ensuring that T is an integer.
Pq-pQ=1 or -1,  which ensures that x and y are integer solutions. This condition can be obtained by solving the 2 linear equations G=0 and J=0 simultaneously and demanding integer solutions for x and y. 
Some steps have been omitted but they can be supplied when needed.  What do you think of this method?
