Let the mixture is X% by mass of $$\displaystyle CuSO_4.5H_2O$$ and 100 - X % by mass of $$\displaystyle MgSO_4.7H_2O$$. 5.0 g of mixture will contain 0.05X g $$\displaystyle CuSO_4.5H_2O$$ and 5.0 - 0.05X g $$\displaystyle MgSO_4.7H_2O$$
The molar masses of $$\displaystyle CuSO_4.5H_2O$$ and $$\displaystyle MgSO_4.7H_2O$$ are 249.7 g/mol and 246.5 g/mol respectively.
The number of moles of $$\displaystyle CuSO_4.5H_2O = \dfrac {0.05X}{249.7} = 2.00 \times 10^{-4}X $$ moles.
The number of moles of $$\displaystyle MgSO_4.7H_2O = \dfrac {5.0-0.05X}{246.5}$$ Total number of moles of water obtained $$\displaystyle = 5 \times 2.00 \times 10^{-4}X + 7 \times \dfrac {5.0-0.05X}{246.5} = 1.00 \times 10^{-3}X + \dfrac {5.0-0.05X}{35.22} $$
Mass of water obtained $$\displaystyle = 5.0 - 3.0 = 2.0 $$ g
Moles of water obtained $$\displaystyle = \dfrac {2.0}{18} = 0.11111$$ Hence, $$\displaystyle 1.00 \times 10^{-3}X + \dfrac {5.0-0.05X}{35.22} = 0.11111 $$
$$\displaystyle 3.522 \times 10^{-2}X + 5.0-0.05X =3.9133 $$
$$\displaystyle 0.01478X =1.0867$$
$$\displaystyle X = 74.4$$ %
Hence, the percentage by mass of $$\displaystyle CuSO_4.5H_2O$$ in the original mixture was 74.4 %