Base numbers problem

sir i am not able to catch error in my code which is giving me TLE .
Question ->

https://www.hackerearth.com/practice/algorithms/searching/binary-search/practice-problems/algorithm/in-another-base-1-e0d0f1ca/

Code -> https://sapphireengine.com/@/934zgh

can you explain your approach?

the formula you have used to find no of digits
is incorrect
int digits=floor(log(a)/log(b)+(mid*log(mid))/log(b))+1;

correct one
int digits=floor(log(a)/log(b)+ mid*(log(mid)/log(b))+1;

i am using this approach to find the number of digits from base 10 to any base , and then counting the values of x (mid) satisfying the formula of this approach till start>end . Approach -> https://www-geeksforgeeks-org.cdn.ampproject.org/v/s/www.geeksforgeeks.org/given-number-n-decimal-base-find-number-digits-base-base-b/amp/?amp_js_v=a6&amp_gsa=1&usqp=mq331AQKKAFQArABIIACAw%3D%3D#aoh=16300580588323&referrer=https%3A%2F%2Fwww.google.com&amp_tf=From%20%1%24s&ampshare=https%3A%2F%2Fwww.geeksforgeeks.org%2Fgiven-number-n-decimal-base-find-number-digits-base-base-b%2F