Not able to solve this

Hi…
I am doing this question from codeforces…
https://codeforces.com/contest/1397/problem/B
This is my solution… which is showing wrong answer…


Could you see here… what i am doing wrong.
Thanks

hello @ashishnnnnn

ur approach looks correct.
basically u r trying to convert array to all possible x^i series and then u r taking that series which has minimum move required. right?

image

use some bigger number here and then try

I thought this would work…


But it is also showing wrong answer

yeah that is correct. as per the condition.
image.

Got accepted…
https://codeforces.com/contest/1397/submission/99525483
Unnecessarily… i was using first for loop in while loop…
Thanks :slight_smile:

yeah i noticed just now

yeah that will repeat again n again even after break

Yaa, I was not incrementing i… and the condition was getting broked in inner for loop.