Page 2 of 3
Posted: Sun May 14, 2006 7:33 am
by jan_holmes
AC.... Finally

Thx to kp,mamun,helloneo...
Posted: Mon May 15, 2006 12:28 am
by C
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
by mamun
It's actually antilog of first 3 digits of mantissa of log(c).
Posted: Mon May 15, 2006 9:34 am
by vinay
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
by mamun
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
by little joey
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
by vinay
ohhhh.

Sorry for the silly question

Posted: Mon May 15, 2006 3:04 pm
by vinay
one last question
How to calculate this antilog?
Posted: Mon May 15, 2006 3:12 pm
by mamun
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
by vinay
thanks

Posted: Mon May 15, 2006 3:56 pm
by vinay
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
by Darko
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
by C
Please help me,I have read all posts here, but have no idea..
My code is:
Re: some doubts
Posted: Tue May 16, 2006 3:43 am
by Cho
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
by vinay
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
