Why it is showing TLE in O(N Log N) complexity?

this is my code

hello @abhi542136

once try using iterative modulo exponentiation

still not working…

ok ok
I forgot to use %p…
now it is working… thanks
…
But, why my 1st code was not working even in (N Log N) time?

…

recursive function are generally slow becuase of function calls

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.