Find all polynomials with real coefficients $P(x),Q(x)$ such that for every real number $x$ we have: $P(Q(x))=P(x)^{2017}$ 
Find all polynomials  with real coefficients $P(x),Q(x)$ such that for every real number $x$ we have: $$P(Q(x))=P(x)^{2017}$$  

This problem is really hard to me!! I have no idea for the solution!
It has been given in summer camp for Iranian MO.
 A: Contrary to my initial guess, we do not need that $2017$ is prime.
Theorem.
Let $N>1$ and $P,Q\in\Bbb C[X]$ such that 
$$ \tag0 P(Q(x))=P(x)^{N}\qquad\text{for infinitely many }x\in\Bbb C.$$
Then either $P$ is constant or there are $n\in\Bbb N$, $a,b,\beta\in\Bbb C$ with $a^{N-1}=b^n$ and 
$$\tag1 P(X)=a(X-\beta)^n,\quad Q(X)=b(X-\beta)^N+\beta. $$
Proof.
First of all, note that the polynomial equation $(0)$  will also hold for all  $x\in\Bbb C$.
If $f$ is a polynomial and $z\in\Bbb C$,  let $v_f(z)$ denote the order of $z$ as root of $f$. So $v_f(z)=0$ for almost all $z$ and  $\sum_{z\in\Bbb C}v_f(z)=\deg f$.
Let $n=\deg P$, $m=\deg Q$.
As we are interested only in non-constant $P$, we can assume $n>0$.
The degree of $P\circ Q$ is $nm$, that of $P^{N}$ is $Nn$. We conclude that $m=N$.
From $(0)$ we see that for $\alpha\in\Bbb C$ and $\beta:=Q(\alpha)$,
$$\tag2 N\cdot {v_P(\alpha)} = v_P(Q(\alpha))\cdot v_{Q-\beta}(\alpha).$$
For $\alpha$ that maximizes $v_P$ (in particular, $v_P(\alpha)>0$), $(2)$ implies $v_{Q-\beta}\ge N$.
Thus $Q-\beta$ is a multiple of $(X-\alpha)^N$, i.e., 
$$\tag3Q(X)=b(X-\alpha)^N+\beta$$
with $\alpha,\beta,b\in\Bbb C$, $b\ne0$.
Then $\alpha$ is the only root of the derivative $Q'(X)=Nb(X-\alpha)^{N-1}$, hence $Q(X)-w$ with $w\ne \beta$ has $N$ distinct, simple roots and at most one of these equals $\beta$. 
Accordingly,  let $w^*$ be a root of $Q(X)-w$ with $w^*\ne\beta$.
Adapting $(2)$, we find $Nv_P(w^*)=v_P(w)$.
By infinite descent, we find that $v_P(w)=0$ for all $w\ne\beta$. In other words, 
$$\tag4P(X)=a(X-\beta)^n$$ for some $a\ne 0$.
Then $\beta$ is the only root of $P(X)^{N}$, hence the only root of $Q(X)-\beta$. Therefore  $\beta=\alpha$. By a quick comparison of leading coefficients, we arrive at $(1)$.
$\square$
Remark: If we know that $P,Q$ have real coefficients, then of course $a,b,\beta$ are real.
