For given $n$ and $m$ print the value LLL...TTT where LLL is the leading $3$ digits of $n^{m}$ and TTT is trailing $3$ digits of $n^{m}$.

Inside Math:

For TTT we just use modular arithmetic and find $n^{m} \text{ (mod 1000)}$

Now, assume that , number of digit of $n^{m}$ is $x$. Hence LLL must be equals to $\lfloor \frac{n^{m}}{10^{x-3}}\rfloor$

How to find x ?

But how to calculate $\lfloor \frac{n^{m}}{10^{x-3}}\rfloor$ ?

Solution of the problem


Reference: