5. Specify all values of $a$ for which the system of equations

$\left\{\begin{array}{c}\log _{\mid x+3}(a x+4 a)=2 \log _{\mid x+3}(x+y), \\ x+1+\sqrt{x^{2}+2 x+y-4}=0\end{array}\right.$ has two distinct solutions, and find these solutions

for each $a$.

(20 points)
Solution: Consider the second equation of the system $x+1+\sqrt{x^{2}+2 x+y-4}=0 \Leftrightarrow\left\{\begin{array}{l}x \leq-1, \\ y=5 .\end{array}\right.$

Therefore, $\left\{\begin{array}{c}\log _{|x+3|}(a x+4 a)=2 \log _{|x+3|}(x+y), \\ x+1+\sqrt{x^{2}+2 x+y-4}=0\end{array} \Leftrightarrow\left\{\begin{array}{c}x^{2}-(a-10) x+25-4 a=0, \\ y=5, \\ -50$. At this point, the equation (*) will have two distinct solutions satisfying the condition $-50, f(-1) \geq 0$, where $f(x)=x^{2}-(a-10) x+25-4 a$. We have $f(-5)=a$, $f(-1)=16-3 a$, leading to the system of inequalities $\left\{\begin{array}{c}a(a-4)>0, \quad a \neq 4,5, \\ 00, \\ 16-3 a \geq 0,\end{array}\right.$, and $a \in(4 ; 4,5) \cup(4,5 ; 16 / 3]$.

Answer: for $a \in(4 ; 4,5) \cup(4,5 ; 16 / 3]$, there are two solutions $x_{1 / 2}=\frac{a-10 \pm \sqrt{a^{2}-4 a}}{2}, y_{1 / 2}=5$.