\(a^3+3a^2+3a+1+b^3+3b^2+3b+1+a+b+2=0\)
\(\Leftrightarrow\left(a+1\right)^3+\left(b+1\right)^3+a+b+2=0\)
\(\Leftrightarrow\left(a+b+2\right)\left(\left(a+1\right)^2-\left(a+1\right)\left(b+1\right)+\left(b+1\right)^2\right)+a+b+2=0\)
\(\Leftrightarrow\left(a+b+2\right)\left(\left(a+1\right)^2-\left(a+1\right)\left(b+1\right)+\dfrac{\left(b+1\right)^2}{4}+\dfrac{3\left(b+1\right)^2}{4}+1\right)=0\)
\(\Leftrightarrow\left(a+b+2\right)\left(\left(a+1-\dfrac{b+1}{2}\right)^2+\dfrac{3\left(b+1\right)^2}{4}+1\right)=0\)
\(\Leftrightarrow a+b+2=0\) (ngoặc to phía sau luôn dương)
\(\Leftrightarrow a+b=-2\)
\(\Rightarrow M=2018\left(a+b\right)^2=2018.\left(-2\right)^2=8072\)