[Bzoj 1857] [SCOI 2010] Conveyor belt (three-point set of three points) __bzoj

Source: Internet
Author: User
Topic link

http://www.lydsy.com/JudgeOnline/problem.php?id=1857 Thinking

http://blog.csdn.net/qpswwww/article/details/44465015 Code

#include <iostream> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <

algorithm> #include <cmath> #define EPS 1e-4 using namespace std;

Double P,q,r,ax,ay,bx,by,cx,cy,dx,dy;

Inline Double dist (double x1,double y1,double x2,double y2) {return sqrt ((x1-x2) * (X1-X2) + (y1-y2) * (Y1-y2));}
    Inline Double calc (double sx,double sy)//Leave conveyor belt AB {double lowerboundx=cx,upperboundx=dx at (Sx,sy);
    Double Lowerboundy=cy,upperboundy=dy; while (Fabs (upperboundx-lowerboundx) >eps| | Fabs (Upperboundy-lowerboundy) >eps) {double midx1=lowerboundx+ (upperboundx-lowerboundx)/3,midx2=upperBoundx
        -(UPPERBOUNDX-LOWERBOUNDX)/3;
        Double midy1=lowerboundy+ (Upperboundy-lowerboundy)/3,midy2=upperboundy-(Upperboundy-lowerboundy)/3;
        Double F1=dist (Ax,ay,sx,sy)/p+dist (sx,sy,midx1,midy1)/r+dist (midx1,midy1,dx,dy)/q;
        Double F2=dist (Ax,ay,sx,sy)/p+dist (sx,sy,midx2,midy2)/r+dist (midx2,midy2,dx,dy)/q; if (f1<F2) Upperboundx=midx2,upperboundy=midy2;
    else lowerboundx=midx1,lowerboundy=midy1;
Return Dist (ax,ay,sx,sy)/p+dist (Sx,sy,lowerboundx,lowerboundy)/r+dist (lowerboundx,lowerboundy,dx,dy)/q; int main () {scanf ("%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf%lf", &ax,&ay,&bx,&by,&cx,&cy,&dx,&
    AMP;DY,&AMP;P,&AMP;Q,&AMP;R);
    Double lowerboundx=ax,upperboundx=bx;
    Double Lowerboundy=ay,upperboundy=by; while (Fabs (upperboundx-lowerboundx) >eps| | Fabs (Upperboundy-lowerboundy) >eps) {double midx1=lowerboundx+ (upperboundx-lowerboundx)/3,midx2=upperBoundx
        -(UPPERBOUNDX-LOWERBOUNDX)/3;
        Double midy1=lowerboundy+ (Upperboundy-lowerboundy)/3,midy2=upperboundy-(Upperboundy-lowerboundy)/3;
        Double F1=calc (midx1,midy1), F2=calc (MIDX2,MIDY2);
        if (F1&LT;F2) upperboundx=midx2,upperboundy=midy2;
    else lowerboundx=midx1,lowerboundy=midy1;
    printf ("%.2lf", Calc (Lowerboundx,lowerboundy));
return 0;
 }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.