5. Given that the 2017 roots of the equation $x^{2017}=1$ are 1, $x_{1}, x_{2}, \cdots, x_{2016}$. Then $\sum_{k=1}^{2016} \frac{1}{1+x_{k}}=$ $\qquad$
5. 1008 .

Given $x_{k}=\mathrm{e}^{\frac{2 k \pi}{2017} \mathrm{i}}(k=1,2, \cdots, 2016)$, we know
$$
\begin{array}{l}
\overline{x_{k}}=\mathrm{e}^{\frac{-2 k \pi}{2017} \mathrm{i}}=\mathrm{e}^{\frac{2(2017-k) \pi}{2017} \mathrm{i}}=x_{2017-k} . \\
\text { Then } \frac{1}{1+x_{k}}+\frac{1}{1+x_{2017-k}} \\
=\frac{1}{1+x_{k}}+\frac{1}{1+\overline{x_{k}}} \\
=\frac{1}{1+x_{k}}+\frac{x_{k} \overline{x_{k}}}{x_{k} \overline{x_{k}}+\overline{x_{k}}}=1 . \\
\text { Therefore, } \sum_{k=1}^{2016} \frac{1}{1+x_{k}}=1008 .
\end{array}
$$