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 1111. Squares

You want solve? See!
Posted by Lifanov 6 Apr 2005 15:37
// find distance between line Ax,Ay Bx,By and point X,Y
double R(double Ax,double Ay,double Bx,double By){
    double r1,r2;
    double x=(Ax+Bx)/2.0;
    double y=(Ay+By)/2.0;
    do{//(fabs(Ax-Bx)>E1 || fabs(Ay-By)>E1){ -> WA 3
        x=(Ax+Bx)/2.0;
        y=(Ay+By)/2.0;
        r1=len(Ax,Ay,X,Y);
        r2=len(Bx,By,X,Y);
        if(r1>r2){
            Ax=x;
            Ay=y;
        }else{
            Bx=x;
            By=y;
        }
    }while(fabs(r1-r2)>E1);
    return (len(x,y,X,Y));
}
when we find distance between P and some line(Ax Ay Bx By) we must compare r1 and r2!
Sorry for my english.
P.S E1=1.0e-10