\(2\left(x+y\right)+xy=x^2+y^2\\ \Leftrightarrow x^2+y^2-2x-2y-xy=0\\ \Leftrightarrow2x^2+2y^2-4x-4y-2xy=0\\ \Leftrightarrow\left(x^2-4x+4\right)+\left(y^2-4y+4\right)+\left(x^2-2xy+y^2\right)=8\\ \Leftrightarrow\left(x-2\right)^2+\left(y-2\right)^2+\left(x-y\right)^2=8\)
\(\Leftrightarrow\begin{matrix}\left(x-2\right)^2=0;&\left(y-2\right)^2=4;&\left(x-y\right)^2=4\\\left(x-2\right)^2=4;&\left(y-2\right)^2=0;&\left(x-y\right)^2=4\\\left(x-2\right)^2=4;&\left(y-2\right)^2=4;&\left(x-y\right)^2=0\end{matrix}\)
\(\Leftrightarrow\begin{matrix}x=2;&y=4\\x=2;&y=0\\x=4;&y=2\\x=0;&y=2\\x=0;&y=0\\x=2;&y=2\end{matrix}\)
Vậy có 6 cặp số thỏa mãn:
\(\left(x;y\right)\in\left\{\left(2;4\right);\left(2;0\right);\left(4;2\right);\left(0;2\right);\left(0;0\right);\left(2;2\right)\right\}\)