5.1. How many triangles with integer sides have a perimeter equal to 2017? (Triangles that differ only in the order of their sides, for example, 17, 1000, 1000 and 1000, 1000, 17, are counted as one triangle.)
Answer: 85008.

Solution. Let the sides of the triangle be $a, b, c$ ordered such that $a \leqslant b \leqslant c$. Then the smaller side $a$ does not exceed $2017 / 3=672 \frac{1}{3}$.

Consider the case of even $a$, i.e., $a=2 k$. Then for $k=1, \ldots, 252$, there will be $k$ triangles each, totaling $253 \cdot 252 / 2=31878$ triangles. For $k=253, \ldots, 336$, there will be $1009-3 k$ triangles each, totaling $1009 \cdot(336-253+1)-3 \cdot(336 \cdot 337 / 2-252 \cdot 253 / 2)=10542$ triangles.

Similarly, for odd $a, a=2 k-1$, for $k=1, \ldots, 252$, there will be $k$ triangles each, totaling $253 \cdot 252 / 2=31878$ triangles. For $k=253, \ldots, 336$, there will be $1011-3 k$ triangles each, totaling $1011 \cdot(336-253+1)-3 \cdot(336 \cdot 337 / 2-252 \cdot 253 / 2)=10710$ triangles.

In total, we get $31878+10542+31878+10710=85008$ triangles.