CROADS - Unofficial Editorial | MAY COOKOFF 2020 | My Approach

This is my approach for Roads to Chefland in CookOff 2020. I found a pattern and wrote the code accordingly. The time complexity of this code is O(log(n)).

Link to Problem Statement
Link to my formatted code

Have a look at my code, any feedback would be great ! :blush:

Link to video

1 Like

https://pastebin.com/iGMaQRtD
Can someone tell what’s wrong in this code.
It’s showing wrong answer on submission.

What’s the idea behind function funn ?

There’s no idea behind it

there must be some logic in using these 2 lines, if u would explain it then it would be better for me to find where it went wrong !

count=(a*((n-a)//(2*a)))+b
count=count+a

First line is combing all odd multiples of power of 2 and second line is connecting that 2^k node to 1st one.