5. Given that $A$ took an integer number of hours to travel from location A to location B, and the number of kilometers $A$ walks per hour is the same as the number of hours it took to travel from location A to location B. $B$ walks 2 kilometers per hour from location A to location B, and rests for 1 hour after every 4 kilometers, and it took a total of 11 hours. Then the distance between location A and location B is $\qquad$ kilometers.
5. 16 .

Let $A$ take $x$ hours to travel from location A to location B, and $B$ rests for a total of $a$ hours on the way.
From the fact that the distances traveled by $A$ and $B$ are equal, we get
$$
x^{2}=2(11-a) \Rightarrow a=11-\frac{x^{2}}{2} \text {. }
$$

Since $B$ rests for $a$ hours, it indicates that $B$ has walked $a$ segments of 4 kilometers and is still less than 4 kilometers away from the destination, and can reach the destination by walking at most another 4 kilometers. Therefore,
$$
\begin{array}{l}
4 a<x^{2}, 4 a+4 \geqslant x^{2} \\
\Rightarrow \frac{44}{3}<x^{2} \leqslant 16 \Rightarrow x=4 .
\end{array}
$$

Thus, $A$ took 4 hours, and the distance between location A and location B is 16 kilometers.