Why do you worry about this? Of course the precision of double is not enough for all these digits, but it would be sufficient if only the 10 first digits were correct. I read the first 10 digits manually into double and got ACCEPTED, I used the exact length of the number in the calculation.
That can't work if the input contains really big numbers. Consider, how you can use the length of a number when calculating log10 of that number. And I think that log and exp are only defined for double, not for long double, so I would not use long double. I used double and cut off all digits after the tenth.
zth@littledaemon$ grep "exp" /usr/include/g++/cmath | grep "long double"
long double exp (long doulbe);
long double frexp(long double, int*);
long double frexp(long double, int*);
zth@littledaemon$ grep "log" /usr/include/g++/cmath | grep "long double"
long double log (long double);
long double log10(long double);
So, apparently, they can use long doubles (FreeBSD 4.5-Release using gcc version 2.95.3 20010315 (release) [FreeBSD])
As far as the rest of your post, I'm confused. you only considered the first ten digits of any number? And I unfortuneately do not know of any way to use the length of a number in regards to logarithms. And I have been re-reading my math textbooks on logarithms to make sure I am not missing anything. (Btw, thanks for taking the time to reply)
i get the same problem and btw..as far as my measly knowledge of c++ is concerned... setprecisio(0) sets it back to the default of infinite precision, no?
well, i've been re-reading my copy of The C++ Programming language (and re-reading it and re-reading it...) and I'm still extremely confused (the documentation sucks (or i do )). In any event, this is what I am working with right now (which still gets a WA)
[cpp]
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main(void) {
double n, p;
cout.unsetf(ios::showpoint);
while (cin >> n >> p) {
cout << exp(log(p)/n) << endl;
}
return 0;
}[/cpp]