$$\require{cancel}$$
$a\frac{d\rho}{da} = -3(P/c^2+\rho) \nonumber$
Plugging in $$\rho \propto a^n$$ we get $$n\rho = -3(P/c^2 + \rho)$$. Solving for $$P$$ for $$n=-3, -4, 0$$ we find $$P=0$$, $$P=\rho c^2/3$$, and $$P = -\rho c^2$$ respectively.