|
|
back to board#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; } Are u crazy? :) 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. |
|
|