B4. Numbers $a, b$ and $c$ form an arithmetic sequence if $b-a=c-b$. Let $a, b, c$ be positive integers forming an arithmetic sequence with $a<b<c$. Let $f(x)=a x^{2}+b x+c$. Two distinct real numbers $r$ and $s$ satisfy $f(r)=s$ and $f(s)=r$. If $r s=2017$, determine the smallest possible value of $a$.
Correct answer: 9 .
Solution 1: Note that
$$
\begin{array}{l}
a r^{2}+b r+c=s \\
a s^{2}+b s+c=r
\end{array}
$$

Subtracting the second equation from the first yields
$$
\begin{aligned}
a\left(r^{2}-s^{2}\right)+b(r-s) & =-(r-s) \Rightarrow a(r+s)(r-s)+(b+1)(r-s)=0 \\
\Rightarrow & (a(r+s)+b+1)(r-s)=0 .
\end{aligned}
$$

Since $r \neq s, r+s=-\frac{b+1}{a}$.
Substituting $s=-\frac{b+1}{a}-r$ into the first equation yields $a r^{2}+b r+c=-\frac{b+1}{a}-r \Rightarrow a r^{2}+(b+1) r+c+\frac{b+1}{a}=0$. Substituting $r=-\frac{b+1}{a}-s$ into the second the equation $a x^{2}+(b+1) x+c+\frac{b+1}{a}=0$. The product of the roots of this equation is $\frac{c}{a}+\frac{b+1}{a^{2}}=2017$.
We also know that the coefficients form an arithmetic sequence, so let $b=a+k, c=a+2 k$. Then we have $\frac{a+2 k}{a}+\frac{a+k+1}{a^{2}}=2017$ and so
$$
k=\frac{2016 a^{2}-1-a}{2 a+1}=1008 a-504+\frac{503-a}{2 a+1}=1008 a-504+\frac{1}{2}\left(\frac{1007}{2 a+1}-1\right) .
$$

Thus, in order for $k$ to be integer, $2 a+1$ must be a factor of $1007=19 \times 53$. Thus, $a=9, a=26$ or $a=503$.
The smallest positive integer $a$ for which $k$ is an integer is $a=9$.
For completeness, we find $k=8594$ and so $b=8603$ and $c=17197$.
Then, $r=-478+3 \sqrt{25163}$ and $s=-478-3 \sqrt{25163}$ satisfy the above relations.
The answer is 9 .

A second solution is provided on the next page.
Solution 2: Note that
$$
\begin{array}{l}
a r^{2}+b r+c=s \\
a s^{2}+b s+c=r
\end{array}
$$

Subtracting the second equation from the first yields
$$
\begin{aligned}
a\left(r^{2}-s^{2}\right)+b(r-s) & =-(r-s) \Rightarrow a(r+s)(r-s)+(b+1)(r-s)=0 \\
\Rightarrow & (a(r+s)+b+1)(r-s)=0,
\end{aligned}
$$
since $r \neq s, r+s=-\frac{b+1}{a}$.
Adding (1) and (2) we get
$$
a\left((r+s)^{2}-2 r s\right)+b(r+s)+2 c=r+s .
$$

Using $r+s=-\frac{b+1}{a}$ and $r s=2017$, we obtain
$$
\frac{(b+1)^{2}}{a}-2 a \cdot 2017-\frac{(b+1)(b-1)}{a}+2 c=0
$$
and then
$$
\frac{2(b+1)}{a}-2 a \cdot 2017+2 c=0
$$
or equivalently
$$
b+1-2017 a^{2}+a c=0 .
$$

Substituting $c=2 b-a$, we get
$$
b+1-2017 a^{2}+2 a b-a^{2}=0,
$$
and so
$$
b=\frac{2018 a^{2}-1}{2 a+1}=\frac{(2 a+1)(1009 a-1)-1007 a}{2 a+1}=1009 a-1-\frac{1007 a}{2 a+1} .
$$

Now, $b$ is integer, so $\frac{1007 a}{2 a+1}$ must be integer. Since $\operatorname{gcd}(a, 2 a+1)=1,2 a+1$ must be a factor of $1007=19 \times 53$, and so $a=9, a=26$ or $a=503$. The smallest value is $a=9$.