Find $m$ and $n$ so that $2m^2+mn+3n^2$ is a multiple of 1017 
Question:
  Find positive integers $m$ and $n$ so that $m+n$ is minimized and $2m^2+mn+3n^2$ is a multiple of 1017.

I found that $1017=3^2\cdot 113$ and $m=113$ and $n=4\cdot 113$ seems be the answer but I can't prove it rigorously.
 A: The main thing is that $$ (-23 | 113 ) = -1,$$ so that, if $2m^2 + mn + 3 n^2$ is divisible by $113,$ both $m$ and $n$ are divisible by $113.$ 
So your question becomes, let $2u^2 + uv + 3 v^2$ be a multiple of $9.$ 
Material on binary quadratic forms and the Legendre symbol are in many number theory books. Given a form,
$$ f(x,y) = A x^2 + B xy + C y^2, $$ we call the discriminant of the form
$$ \Delta = B^2 - 4 A C,  $$
same as for the quadratic formula. For your form, $\Delta = -23.$
Here is a Proposition that is used over and over again on this site. Suppose we have an odd prime $q$ such that, not only does $q$ not divide $\Delta,$ but $(\Delta | q) = -1.$ If  $ A x^2 + B xy + C y^2 $ is divisible by $q,$ then both $x,y$ are divisible by $q,$ so that $ A x^2 + B xy + C y^2 $ is actually divisible by $q^2.$
PROOF if $q$ divides both $A,B$ then $q$ divides $\Delta,$ so that is ruled out. If $q$ divides $A$ but not $B,$ then $\Delta \equiv B^2 \pmod q,$ which contradicts $(\Delta | q) = -1.$ So that does not happen either, and $A$ is not divisible by $q.$ Also $q$ is odd, meaning not equal to $2.$ it follows that  $ A x^2 + B xy + C y^2 $ is divisible by $q$ if and only if $ 4A(A x^2 + B xy + C y^2) $ is divisible by $q.$
We are considering
$$ 4A(A x^2 + B xy + C y^2) \equiv 0 \pmod q, $$
$$ 4A^2 x^2 + 4AB xy + 4AC y^2 \equiv 0 \pmod q, $$
$$ 4A^2 x^2 + 4AB xy + B^2 y^2 - B^2 y^2 + 4AC y^2 \equiv 0 \pmod q, $$
$$ (4A^2 x^2 + 4AB xy + B^2 y^2) - (B^2 y^2 - 4AC y^2) \equiv 0 \pmod q, $$
$$ (2Ax + By)^2 - (B^2  - 4AC)y^2 \equiv 0 \pmod q, $$
$$ (2Ax + By)^2 - \Delta y^2 \equiv 0 \pmod q, $$
$$ (2Ax + By)^2 \equiv \Delta y^2  \pmod q. $$
IF we ASSUME $y \neq 0 \pmod q,$ then $y$ has a multiplicative inverse and
$$ \left(\frac{2Ax + By}{y}\right)^2 \equiv \Delta   \pmod q. $$ This contradicts the hypothesis  $(\Delta | q) = -1,$ showing that actually $y$ is divisible by $q.$ Therefore $Ax^2$ is also divisible by $q,$ but $A$ is not, so also $x$ is divisible by $q.$
