Solution
= Solution
The <selective phase rotation> $R_g^\phi$ multiplies the component parallel to $|g\rangle$ by $e^{i\phi}$ and fixes its orthogonal complement. Therefore
$$
\boxed{R_g^\phi U|00\rangle
=e^{i\phi}\sqrt p\,|g\rangle+\sqrt{1-p}\,|b\rangle.}
$$