Xét hàm \(f\left(x\right)=\dfrac{x+m}{x+1}\) có \(f'\left(x\right)=\dfrac{\left(x+m\right)'\left(x+1\right)-\left(x+m\right)\left(x+1\right)'}{\left(x+1\right)^2}=\dfrac{1-m}{\left(x-1\right)^2}\)
Cho \(f'\left(x\right)=\dfrac{1-m}{\left(x-1\right)^2}=0\Leftrightarrow m=1\)
Khi đó \(f\left(x\right)=\dfrac{x+1}{x+1}=1\)
\(\Rightarrow max_{\left[0;1\right]}\left|f\left(x\right)\right|+min_{\left[0;1\right]}\left|f\left(x\right)\right|=1+1=2\) ( thỏa mãn )
Vậy \(m=1\) thỏa mãn bài toán.
Xét \(m\ne1\), ta thấy \(f\left(x\right)\) đơn điệu trên \(\left[0;1\right]\), xét các trường hợp:
*) \(f\left(0\right).f\left(1\right)\le0\Leftrightarrow\dfrac{m+1}{2}\cdot m\le0\) \(\Leftrightarrow-1\le m\le0\)
\(\Rightarrow\left\{{}\begin{matrix}min_{\left[0;1\right]}\left|f\left(x\right)\right|=0\\max_{\left[0;1\right]}\left|f\left(x\right)\right|=max\left\{\dfrac{\left|m+1\right|}{2};\left|m\right|\right\}\end{matrix}\right.\)
Khi đó: \(max_{\left[0;1\right]}\left|f\left(x\right)\right|+min_{\left[0;1\right]}\left|f\left(x\right)\right|=2\)
\(\Leftrightarrow0+\dfrac{\left|\dfrac{m+1}{2}+m\right|+\left|\dfrac{m+1}{2}-m\right|}{2}=2\)
\(\Leftrightarrow\left|\dfrac{3m+1}{2}\right|+\left|\dfrac{-m+1}{2}\right|=4\)
\(\Leftrightarrow\left|3m+1\right|+\left|m-1\right|=8\) (1)
Xét các trường hợp:
+) \(m\le\dfrac{-1}{3}\) : \(\left(1\right)\Leftrightarrow-3m-1-m+1=8\Leftrightarrow m=-2\) ( loại )
+) \(m\ge1\) : \(\left(1\right)\Leftrightarrow3m+1+m-1=8\Leftrightarrow m=2\) ( loại )
+) \(-\dfrac{1}{3}< m< 1\) : \(\left(1\right)\Leftrightarrow3m+1-m+1=8\Leftrightarrow m=3\) ( loại )
*) \(f\left(0\right)\cdot f\left(1\right)>0\Leftrightarrow\dfrac{m+1}{2}\cdot m>0\Leftrightarrow\left[{}\begin{matrix}m>0\\m< -1\end{matrix}\right.\)
\(\Rightarrow\left\{{}\begin{matrix}min_{\left[0;1\right]}\left|f\left(x\right)\right|=min\left\{\dfrac{\left|m+1\right|}{2};\left|m\right|\right\}\\max_{\left[0;1\right]}\left|f\left(x\right)\right|=max\left\{\dfrac{\left|m+1\right|}{2};\left|m\right|\right\}\end{matrix}\right.\)
Khi đó: \(min_{\left[0;1\right]}\left|f\left(x\right)\right|+max_{\left[0;1\right]}\left|f\left(x\right)\right|=2\)
\(\Leftrightarrow\dfrac{\left|\left|\dfrac{m+1}{2}+m\right|-\left|\dfrac{m+1}{2}-m\right|\right|}{2}+\dfrac{\left|\left|\dfrac{m+1}{2}+m\right|\right|+\left|\left|\dfrac{m+1}{2}-m\right|\right|}{2}=2\)
\(\Leftrightarrow\dfrac{\left|\left|3m+1\right|-\left|m-1\right|\right|}{4}+\dfrac{\left|\left|3m+1\right|+\left|m-1\right|\right|}{4}=2\)
\(\Leftrightarrow\dfrac{2\left|3m+1\right|}{4}=2\)
\(\Leftrightarrow\left|3m+1\right|=4\)
\(\Leftrightarrow\left[{}\begin{matrix}m=1\\m=\dfrac{-5}{3}\end{matrix}\right.\)
Tóm lại ở cả 2 trường hợp thì ta có \(m\in\left\{1;\dfrac{-5}{3}\right\}\) thỏa mãn đề bài.
Vậy \(S=\left\{1;\dfrac{-5}{3}\right\}\) có \(2\) phần tử.