I have plugged $p/q$ into the equation. Not sure what to do next. Suppose $a_0,a_1,\dots,a_n$are integers and $a_0\neq 0$ and $a_n\neq 0$.Consider the polynomial 

$f(x)=a_0x^n+a_1x^{n-1}+\dots+a_{n-1}x+a_n$.

If $p\neq 0,q>0$ are coprime integers and $p/q$ is a rational root of equation $f(x)=0$,then show that $p|a_n$ and $q|a_0$, and that if $q>1$,then $p-mq$ divides $f(m)$ for any integer $m$.
 A: Plug in

$$a_0\left({p\over q}\right)^n+a_1\left({p\over q}\right)^{n-1}+\ldots +a_{n-1}\left({p\over q}\right)+a_n=0$$

Then move $a_n$ to the RHS and clear denominators

$$p\left(a_0p^{n-1}+a_1p^{n-2}q+\ldots +a_{n-2}pq^{n-2}+a_{n-1}q^{n-1}\right)=-a_nq^n$$

Since $p$ divides the LHS it divides the RHS. Since $p\not\mid q$ it must be that $p|a_n$. Similarly by moving the first term over instead of the last we get

$$q\left(a_nq^{n-1}+a_{n-1}pq^{n-2}+\ldots +a_1p^{n-1}q+a_0p^n\right)=-a_0p^n$$

Again $q\not\mid p$ so $q\mid a_0$.
For the second part we just expand

$$f(m)=a_0m^n+\ldots+a_{n-1}m+a_n$$

Now subtract $q^nf(p/q)=0$ from $q^n$ times this.
$$q^nf(m)=q^nf(m)-q^nf(p/q)=a_0
\big((mq)^n-p^n\big)+a_1q\big((mq)^{n-1}-p^{n-1}\big)+\ldots+q^{n-1}a_{n-1}\big((mq)-p\big).$$
Then $q^nf(m)$ is divisible by $p-mq$ because

$$x^n-y^n=(x-y)(x^{n-1}+x^{n-2}y+\ldots +xy^{n-2}+y^{n-1}).$$

Clearly $\gcd(p-mq, q)$ divides $q$ and $p$ since $p=(p-mq)+m(q)$ hence coprimality implies this gcd is $1$. Hence $p-mq$ divides $f(m)$ if the former is a non-zero integer by the fundamental theorem of arithmetic--or a slightly weaker theorem that says $a|bc$ and $\gcd(a,b)=1$ implies $a|c$. Since $q>1$ we have that $p-mq\ne 0$ for all $m$ and the rest is history.
