Help to DEBUG KBIGNUM

Can anyone help me to debug the code here? I spent whole day on this problem, but I am unable to get it right.

I am AWARE of it failing on some test cases, and I know what those test cases are. I specifically need help in debugging the code and correcting it. I used the approach described by @gkcs in his video editorial, but I think I messed up somewhere.

I would be grateful if anyone could help. :slight_smile:

Why don’t you try the approach given on this link? It’s pretty simple than your one!

And sorry, I couldn’t debug your code!

1 Like

@vijju123

yes,at hackerrank it is given…but let me debug,if I could.

1 Like

I wish to do it via approach given by gkcs in his video editorial. Much more because I am unable to figure out whats wrong, I want to know where I am lacking. Of course, other approach might be simpler, but my motive is to find and rectify my mistakes and then to solve the problem. Thanks for your considerations though! :slight_smile:

I would appreciate that dear! Try to watch gkcs’ explanation in his video if you are unable to get my logic or “why did I do that”.

Hello @vijju123 !
I can’t debug your code but I was having WA too initially, it was due to the following reason.
1> I proved the answer to be of the form A.((10^(lenA . N) - 1) / (10 ^ lenA - 1)). Now , I knew that we can’t just simple do a modulo operation in division so I was finding the inverse modulo with fermat’s little theorem, which was a wrong choice because it works only if the number whose inverse you want to find and M are co-primes which was not the case here. So, if you have that logic be careful. Also, Modulo operations too. :slight_smile:
Try this tc
1
526 996 956577277
output: 535743493

1 Like

I sincerely thank all the concerned people for their time. :slight_smile:

I have added a solution to the video description, just in case :slight_smile:

Thats what I call icing on a cake!! Thanks a lot bud!! Really appreciate the time you devoted to it!!! :slight_smile: