About form $ax^2+bx+c$ always representing a perfect square number I found that if $f(x)=ax^2+bx+c(a,b,c\in\mathbb{Z},a\neq0)$ always form a pefect square number for all $x\in\mathbb{Z}$,Then there must exists $s,t\in\mathbb{Z}$ so that  $f(x)=(sx+t)^2$,but I cannot prove it.
Since $f(0)=c$ is a pefect square,there exists $t^2=c$. Then consider any prime $p|t$,$f(p)=ap^2+bp+t^2=n^2$,so $p|n$,$p^2|n^2$.Because $p^2|t^2$,there must be $p|b$ for all $p|t$,so $t|b$,It should be $t|b$ since I hope b=2st,but I get stuck here.
What's more ,by consider $b=\frac{f(1)-f(-1)}{2}$ and perfect square module 4,I can prove b is a even number.
 A: This is a special case of Hilbert's irreducibility theorem, as noted explicitly
in
Wikipedia's 
article on that theorem.  Specializing the proof yields the following
argument, for which it is enough to assume that $f(x)$ takes square values
for a few sufficiently large consecutive integer values of $x$.
For integers $n$, let $g_n = \sqrt{f(n)}$.
By hypothesis each $g_n$ is an integer.
On the other hand, there is some constant $C$ such that 
the second finite difference $d_n := g_{n+2} - 2 g_{n+1} + g_n$ 
satisfies $|d_n| < C/n$ for large $n$.  (This can be seen in several ways,
e.g. by applying Rolle's theorem twice, or by expanding
$d_n$ in a Laurent series about $n = \infty$.)  Since $d_n$ is an integer,
it follows that $d_n = 0$ for large $n$, say $n>N_0$.
But this means that $g_n$ is eventually linear: there exist integers $A,B$
such that $g_n = An+B$ for all $n > N_0$.  Then $f(n) = (An+B)^2$ for all
$n > N_0$, which makes $f(x) = (Ax+B)^2$ identically, QED.
A: Solutions of the equation: 
$$ax^2-by^2+cx-dy+q=0$$
you can record if the root of the whole: $k=\sqrt{(c-d)^2-4q(a-b)}$
Then using the solutions of the equation Pell: $p^2-abs^2=\pm1$
Then the formula of the solution, you can write:
$$x=\frac{\pm1}{2(a-b)}(((d-c)\pm{k})p^2+2(bk\mp(bc-ad))ps+b(a(d+c)-2bc\pm{ak})s^2)$$
$$y=\frac{\pm1}{2(a-b)}(((d-c)\pm{k})p^2+2(ak\mp(bc-ad))ps-a(b(d+c)-2ad\mp{bk})s^2)$$
If the root is a need to find out if this is equivalent to the quadratic form in which the root of the whole. This is usually accomplished this replacement: $x$ in such number $x+ty$
Forgot to say. The characters inside the brackets do not depend on the sign of the Pell equation. 
It depends only before $\pm{1}$
