MATBREAK TLE!

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

why my o(n) solution is getting TLE?

Mine kept giving TLE, then I used a fast logic for powers which worked

fast logic for powers?

but it is o(nlogn) right? and this solution is o(n).