What is problem in my code

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 50000000000009999ll
using ld = long double;
using ull = unsigned long long;
unordered_map<ll,ll> mp;
ll solve(ll n)
{
if(n==1ll)
return 1;
if(mp.count(n))
return mp[n];
mp[n]=max(n,solve(n/2)+solve(n/3)+solve(n/4));
return mp[n];
}
int main()
{
ll n;
cin>>n;
cout<<solve(n);

return 0;

}

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define INF 50000000000009999ll
using ld = long double;
using ull = unsigned long long;
unordered_map<ll,ll> mp;
ll solve(ll n)
{
if(n==1ll)
return 1;
if(mp.count(n))
return mp[n];
mp[n]=max(n,solve(n/2)+solve(n/3)+solve(n/4));
return mp[n];
}
int main()
{
ll n;
cin>>n;
cout<<solve(n);

return 0;

}

@sachinkumar24051999,

  • Line 10: if(n==1ll) return 1;
    Correction: if(n<=1ll) return n;

@sachinkumar24051999
I see you have already received 100 for this question
So I’m closing this doubt

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like