What is wrong with my code

Hey!

What is wrong in my code. Please help me.
contest : contest
problem : Minimalistic
my code : solution

Thanks in advance

i did the same thing
apparently the accepted code is-

while(n>2)
 {
        if(n==5 ) n-=3;
        else if(n%5 == 0) n/=5;
        else n-=3;
        ans++;
}

this code clearly fails in the following tc-
1
20

correct:6
accpeted:-1
i tried against ranks 1,2,3 and all of them gave the same error

its not always optimal to do n/5 if n is divisible by 5

2 Likes

Yes you are right it can be seen that 20 can be changed to 2.
20 → 17 → 14 → 11 → 8 → 5 → 2 in six step

so what can be a valid solution for it. i have a tle solution .Does anyone knows .Please reply it help me improve !!
Thanks

I think my solution is correct and as per @tamo11 also my solution is correct.
See my solution, you will know what my logic is.

1 Like