Codeforces 8d two friends three points + two points + computational ry

Source: Internet
Author: User

Question link: Click the open link


Question: Click to open the link

Distance from house to shop, distance from oblique edge to cinema

# Include <stdio. h> # include <string. h> # include <iostream> # include <algorithm> # include <math. h> # include <set> # include <queue> # include <vector> # include <map> using namespace STD; # define ll int # define N 90 # define PI 3.1415926535898 # define EPS 1e-10double T1, T2; struct node {Double X, Y;} C, H, S; double dist (double X1, double Y1, double X2, double Y2) {return SQRT (x1-x2) * (x1-x2) + (y1-y2) * (y1-y2 ));} double dist (node A, Node B) {return SQRT (. x-b.x) * (. x-b.x) +. y-b.y) * (. y-b.y);} double work (double du) {node x = {S. x * (1-du) + H. x * Du, S. y * (1-du) + H. y * du}; double AC = dist (x, C), as = dist (x, S), Ah = dist (x, H ); if (AC + Ah <= t2 & AC + as <= T1) return min (t2-ah, t1-as); double L = 0, r = 1.0; for (INT I = 1; I <= 300; I ++) {double mid = (L + r)/2; Node B = {C. x * (1-mid) + X. x * mid, C. y * (1-mid) + X. y * mid}; double BC = dist (B, c), BS = dist (B, S), BH = dist (B, H ); if (BC + bH <= t2 & BC + BS <= T1) L = mid; else r = mid;} Node B = {C. x * (1-L) + X. x * l, C. y * (1-L) + X. y * l}; return dist (B, c);} int main () {ll I, j, U, V; while (CIN> T1> T2) {CIN> C. x> C. y; CIN> H. x> H. y; CIN> S. x> S. y; Double A = dist (C, S), B = dist (C, H), c = dist (H, S ); if (B + T2> = A + C) {printf ("%. 8lf \ n ", min (a + t1 + C, B + T2); continue;} t1 + = a + EPS; T2 + = B + EPS; double L = 0, r = 1.0, ANS = 0; for (I = 1; I <= 300; I ++) {double mid1 = (L + r)/2.0, mid2 = (mid1 + r)/2.0; double ans1 = work (mid1), ans2 = work (mid2); If (ans1 <ans2) L = mid1; else r = mid2; ans = max (ANS, max (ans1, ans2);} printf ("%. 8lf \ n ", ANS);} 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.