ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1336. Problem of Ben Betsalel

#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.