I did this question using naive approach in 0.32 seconds.
But to do better i did it with binary lifting which resulted in 0.35 seconds.
I tried so many times but could not do better.
Can someone plz help me in finding out whether something is wrong with my binary lifting approach.
Solution using binary lifting- https://ideone.com/vjf7wj