Did not understand how to solve the given code

please tell how we take input as 12 and output 13 please explain

Coin 12 can be exchanged with 12/2, 12/3 and 12/4
Giving 6+4+3=13
This way input 12 gives output as 13.

So here you can do something like this:

dp[0]=0;dp[1]=1;dp[2]=2;dp[3]=3;dp[4]=4; //Initializing

for(lli i=5;i<=n;i++){
dp[i]=max(i,dp[i/2]+dp[i/3]+dp[i/4]);
}

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.