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 1153. Supercomputer

i use simple algorhit. it works on my test. Why Wa 6?
Posted by Alexander Prudaev 10 Oct 2006 14:28
I test it on random big integers and it work,
but i get WA#6 What's wrong?
I am sure, My program always gives right answer.

#include <stdio.h>

class ML  // my long integer
....

ML sqrt(ML x)
{
    ML l(1);
    ML r=x;
    ML m;
    ML E(1);
    while (l+E!=r)
    {
        m=(l+r)/2;
        if (m*m>x) r=m; else l=m;
    }
    return l;
}

int main()
{
    ML a;
    a.read();
    sqrt(a*2).write();
    return 0;
}