← Back to topics
Topic

Number of Digits fails for me on 4 test case any advice ?

Dgleich
Here is the code :
REMOVED*
harta01
One obvious bug is %ld for n( long long)

It must be %lld
Dgleich
well it fails again...
demjan0001
well here is mistake ...
rez = k*l1/l2
it has to be
rez = int( k*l1/double(l2) );
try now ...
Dgleich
Failing again :)
demjan0001
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) ...
Dgleich
You submitted code like this ?
REMOVED*
this doesn't work for me ...
demjan0001
i submited solution like this:

DELETED

you need to use long long ...
Dgleich
It works thanks, but I still don't understand what was wrong ? :D
gates
probably some precision error.
RobertGerbicz
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.
darkspirit
You are absolutelyright!!!
Any explanation though?