
Here is the code :
REMOVED*

One obvious bug is %ld for n( long long)
It must be %lld

well here is mistake ...
rez = k*l1/l2
it has to be
rez = int( k*l1/double(l2) );
try now ...

i am not sure why it doesn't work ...
when i submited with log(n) / log(10) it fails on 4th test case, but when i submited with log10(n) it passed all tests cases ...
i am not sure why, because: logc N = logk ( N ) / logk (c) ...
so log10(N) = log(N) / log(10) ...

You submitted code like this ?
REMOVED*
this doesn't work for me ...

It works thanks, but I still don't understand what was wrong ? :D

probably some precision error.

At the 4-th test case n is a power of ten so for that n^k is a power of ten, meaning that the base 10 logarithm is an integer, so you can easily get an error.
In my solution I'm treat the n=10^e as a special case.

You are absolutelyright!!!
Any explanation though?