Help with mistakes

prob: https://codeforces.com/contest/1485/problem/A

code: https://ide.codingblocks.com/s/433259

what are the logical mistakes I’m making here?

hello @raghav007

look at the constrains, it is not solvable by dp.

	b += 1;
	option2 = solve(a, b, dp ) + 1;

	int ans = min(option1, option2);
	dp[a][b] = ans;
	return ans;

the line b+=1 is chaging the value of b.
dont do that instead pass b+1 direclty in ur function call.

in the editorial they are saying increase b upto a certain number how do we determine that number

just brute force upto some big number

log2(10^9)=29 so iterate for 30-40

will this work : we start a loop for b = log(a) and decrease b and each iteration we use a while loop to divide a by b until a is 0 and store the answer and also add to it how many times we have added one to(the number of iteration)

yeah its the same approach.

u need to repeat this for b=[1…log(a)] and pick that answer which take less steps

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.