MXMLCM why this code is giving TLE

I have used the sieve method for factorization. I am not getting why it is giving TLE.

Question - MXMLCM - MXMLCM Problem - CodeChef

My code - XlHuDM - Online C++0x Compiler & Debugging Tool -

Can anyone answer that why people write their own power function instead of using predefined pow() function??

Bro, my approach is similar to yours instead I have calculated the factors before the test case and stored them in an map array i.e, map<int,int> mp[10001]. Mine one got accepted.

1 Like

In this question, I have used predefined ‘pow()’ function rather than writing my own.
We write our own ‘power’ function in the cases where we need to calculate very large powers say for instance 2^100%1000000007. Since 2^100 is a very large number, predefined ‘pow()’ gives undesired value.