Page 2 of 3
Posted: Sun May 14, 2006 7:33 am
AC.... Finally Thx to kp,mamun,helloneo...

Posted: Mon May 15, 2006 12:28 am
kp wrote:Let C = A^B,

lg(C) = B*lg(A), lg - decimal logarithm lg(x) = ln(X)/ln(10).
First three digits of C are first three digits of mantissa of lg(C).

That's how I got AC (not sure about mathematical correctness).
kp: I really don't understand,why first three digits of C are first three digits of mantissa of lg(C)?? For example,
lg(123456)= 5.091512... where is 123 ???
or can someone else explain it to me ??

Posted: Mon May 15, 2006 7:12 am
It's actually antilog of first 3 digits of mantissa of log(c).

Posted: Mon May 15, 2006 9:34 am
kp wrote:Let C = A^B,

lg(C) = B*lg(A), lg - decimal logarithm lg(x) = ln(X)/ln(10).
First three digits of C are first three digits of mantissa of lg(C).

That's how I got AC (not sure about mathematical correctness).
how do u calulate mantissa in c++?

Posted: Mon May 15, 2006 10:59 am
It's not a question of C++. It's simple maths.

Of a number, say 12.589, .589 is the mantissa. So you can calculate mantissa of a vlaue, x
mantissa(x) = x - floor(x)
You can use frexp() function in C/C++.

### some doubts

Posted: Mon May 15, 2006 12:24 pm
I also calculated the first three digits using <math.h> and got accepted, but I still have some doubts about precision.
How can we be sure that a 100-million digit number that starts off "123999999999999999999999999..." is not printed as "124..." without doing bigint calculus?

Posted: Mon May 15, 2006 1:41 pm
ohhhh. Sorry for the silly question

Posted: Mon May 15, 2006 3:04 pm
one last question
How to calculate this antilog?

Posted: Mon May 15, 2006 3:12 pm
If you do log calculation in base 10 ie. log10() then use pow(10,x) for antilog and if base is e ie. log(), then use exp().

Posted: Mon May 15, 2006 3:15 pm
thanks

Posted: Mon May 15, 2006 3:56 pm
I need some help for the leading part..
what is the problem with the following code snippet :

double dd=(double)k*log(mm);
char buf1[30];
sprintf(buf1,"%.Lf",exp(dd));

I have got WA

Posted: Mon May 15, 2006 5:14 pm
I did the first three with fast exponentiation, I just kept moving the decimal point so it wouldn't go into infinity. Never occured to me that I could've used logs

### why WR

Posted: Mon May 15, 2006 5:56 pm
My code is:

Code: Select all

``````AC ed..
``````

### Re: some doubts

Posted: Tue May 16, 2006 3:43 am
little joey wrote:I also calculated the first three digits using <math.h> and got accepted, but I still have some doubts about precision.
How can we be sure that a 100-million digit number that starts off "123999999999999999999999999..." is not printed as "124..." without doing bigint calculus?
I think the 4th to 15th digit can be considered as some sort of pseudo-random number, then the probability that all these digits being 9 is exponentially small.

Posted: Tue May 16, 2006 7:45 am
Darko wrote:I did the first three with fast exponentiation, I just kept moving the decimal point so it wouldn't go into infinity.
For the trailing part I used the Square-and-multiply method .
How to use the same for the leading .. I really can't understand