My issue
Sir/mam i think my code is correct as i had seen others submissions too. but it is showing TLE in my case.
please tell how can i optimize my code without using any other method
My code
#include <iostream>
using namespace std;
long solve(long n)
{
if(n>=12)
return solve(n/2) + solve(n/3)+ solve( n/4);
else
return n;
}
int main() {
long n;
while(cin>>n)
cout<<solve(n)<<endl;
return 0;
}
Problem Link: COINS Problem - CodeChef