|
|
вернуться в форумi have problems with 12 test.What is wrong Послано Igor 21 сен 2005 21:06 #include <iostream> #include <math.h> using namespace std; unsigned long long n,b,c,k,m; long double f,i; int main () { cin >>n; b=2; if (modf(sqrt((double)n),&i)==0) {cout <<(unsigned long long)sqrt((double)n)<<"\n"; cout <<"1"<<"\n";} else { for ( ;b<=n;b++) { f=modfl(sqrt((long double)n*(double)(b*b*b)),&i); if (f==0) break; } m=(unsigned long long )sqrt((long double)n*(double)(b*b*b)); cout <<m<<"\n"; cout <<b<<"\n"; } return 0; } Re: i have problems with 12 test.What is wrong Послано PSV 3 ноя 2006 06:27 Are u crazy? :) Re: i have problems with 12 test.What is wrong I had WA12 when I wrote v*v for integer v - it overflowed. Perhaps your long double (equals double for VC++) overflows too. Try putting everything into __int64, no floating point. I use prime factorization for that. |
|
|