Ta có \(x+y+z=0\)
\(\Rightarrow x+y=-z\)
\(\Leftrightarrow\left(x+y\right)^3=-z^3\)
\(\Leftrightarrow x^3+y^3+z^3+3xy\left(x+y\right)=0\)
\(\Leftrightarrow x^3+y^3+z^3-3xyz=0\)
\(\Leftrightarrow x^3+y^3+z^3=3xyz\)
Đặt \(A=2xy^2+2yz^2+2zx^2+3xyz=2xy^2+2yz^2+2zx^2+x^3+y^3+z^3\)
\(=x^2\left(2z+x\right)+y^2\left(2x+y\right)+z^2\left(2y+z\right)\)
Do \(x+y+z=0\Rightarrow\left\{{}\begin{matrix}2z+x=z-y\\2x+y=x-z\\2y+z=y-x\end{matrix}\right.\)
\(\)\(\Rightarrow A=x^2\left(z-y\right)+y^2\left(x-z\right)+z^2\left(y-x\right)\)
\(=x^2\left(z-y\right)-y^2\left(z-y+y-x\right)+z^2\left(y-x\right)\)
\(=\left(x^2-y^2\right)\left(z-y\right)-\left(z^2-y^2\right)\left(x-y\right)\)
\(=\left(x-y\right)\left(z-y\right)\left(x+y-z-y\right)\)
\(=\left(x-y\right)\left(y-z\right)\left(z-x\right)\)
\(\Rightarrow\dfrac{2018\left(x-y\right)\left(y-z\right)\left(x-z\right)}{A}=2018\)
\(\Rightarrow P=2018\)
Vậy \(P=2018\)