The charge on the plates of the first capacitor when connected against the potential difference V is given by
Q==CV2V

When both the capacitors are connected, from the conservation of charge, it can be written that
2V=⇒2V′+2V′V′=(21V)
where, V′ is the new potential difference across each capacitor.
The formula to calculate the energy stored in the first capacitor is given by
E1===21×C×V221×2×V2V2...(1)
For the second case, the energy stored in the combination of capacitor is given by
E2===21nCV′221×2×4V2×2(2V2)...(2)
Divide equation (2) by equation (1) to obtain the required ratio of the stored energy.
E1E2==V22V2(21)