Bzoj 1857 scoi 2010 Conveyor Belt Three-part method

Source: Internet
Author: User

The main topic: give the plane on the two line segment, in the two segments walk has a certain speed, on the other plane walk also has a certain speed, ask from a point to D point at least how much time required.


Thought: It seems that three points, probably feel it, anyway, will not be proven.


CODE:

#include <cmath> #include <cstdio> #include <iomanip> #include <cstring> #include <iostream > #include <algorithm> #define EPS 1e-7#define INF 1e15using namespace std;struct point{double x, y; Point (Double _,double __): X (_), Y (__) {}point () {}void Read () {scanf ("%lf%lf", &x,&y);} Point operator + (const-point-&a) const {return point (x + a.x,y + a.y);} Point operator-(const point &a) const {return point (X-A.X,Y-A.Y);} Point operator * (double A) const {return point (x * a,y * a);} Point operator/(double a) const {return point (x/a,y/a);}} A,b,c,d;inline Double Calc (const point &a,const point &b) {return sqrt ((a.x-b.x) * (a.x-b.x) + (A.Y-B.Y) * (A . y-b.y));} Double v1,v2,v3;double tridivide (const point &p,point l,point R) {When (Calc (l,r) > EPS) {point u = (r-l)/3.0;  Point P1 = l + u,p2 = p1 + u;double ans1 = Calc (a,p)/v1 + calc (p1,d)/v2 + calc (p,p1)/v3;double ans2 = Calc (a,p)/v1 + Calc (p2,d)/v2 + calc (p,p2)/V3;if (anS1 > Ans2) L = P1;elser = p2;} Return Calc (a,p)/v1 + calc (l,d)/v2 + calc (p,l)/v3;} Double Tridivide (Point L,point R) {When (Calc (l,r) > EPS) {point u = (r-l)/3.0; Point P1 = l + u,p2 = p1 + u;double ans1 = Tridivide (p1,c,d), ans2 = Tridivide (p2,c,d), if (Ans1 > Ans2) L = P1;elser = P2; }return tridivide (l,c,d);} int main () {A.read (), B.read (), C.read (), D.read (); scanf ("%lf%lf%lf", &v1,&v2,&v3); cout << Fixed < < Setprecision (2) << tridivide (A, b) << Endl;return 0;}


Bzoj 1857 scoi 2010 Conveyor Belt Three-part method

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.