The initial charge of the capacitor C1 is $q_0$ and capacitance is $C_1$ and capacitor C2 is $0$ and capacitance is $C_2$. When the switch S is closed the first capacitor charges the second one and during that process some energy has been dissipated in the resistor, thus transferred to heat. Find how much energy is lost to heat? The answer must be in terms of given quantities, which means that I am looking for a formula rather than a numberic answer.
In order to solve this problem, I thought that it will be beneficial to find $I(t) $ and then find the power in the equation $ P = I(t)^2 R$. After finding the power, I thought that it is a good idea to integrate from the boundries 0 to infinity. However, I was not able to find the $I(t)$ since there are two capacitors with a different capacitance.