What is wrong with this code?

hard
puppygcd

#1

Problem code puppygcd of ltime26

I followed the approach of the editorial and still am getting tle. Can you plz tell me why? Similar solutions in practice session got ac.

https://www.codechef.com/viewsolution/7579923

I also need help with preprocessed array. How was it calculated? I applied a bruteforce to generate it but it is taking a lot of time ( don’t know exact as i got bored and stopped the process in between). In my solution i used the array in authors code.


#2

@dragonemperor I am also confused how the preprocessed array is calculated. Why isn’t anybody answering it?