BNU 4260--trick or Treat —————— "three points for parabolic apex"

Source: Internet
Author: User

ial JudgePrev Submit Status Statistics discuss Next

Johnny and his friends has decided to spend Halloween night doing the usual candy collection from the households of their Village. As the village is too big for a single group to collect the candy from all houses sequentially, Johnny and his friends hav E decided to split-so, each of them goes to a different house, collects the candy (or wreaks havoc if the residents Don ' t give out candy), and returns to a meeting point arranged in advance.

There are  n  houses in the village, the positions of which can is identified with Their Cartesian coordinates on the Euclidean plane. Johnny ' s gang is also made up Of  n  people (including Johnny himself). They has decided to distribute the candy after everybody comes back with their booty. The houses might are far away, but Johnny ' s interest are in eating the candy as soon as possible.

Keeping in mind so, because of their response to the hospitality of some villagers, some children might is wanted by the Local authorities, they has agreed to fix the meeting point by the river running through the village, which y = 0. Note that there is houses on both sides of the river, and some of the houses is houseboats (y = 0). T He walking speed of every-is 1 meter per second, and they can move along any direction on the plane.

At exactly midnight, each child would knock on the door of the house he had chosen, collect the candy instantaneously, and Walk back along the shortest route to the meeting point. Tell Johnny at what time he'll be able to start eating the candy.

Input

Each test case is starts with a line indicating the number n of houses ( 1<=n<=50 000). The next n Lines describe the positions of the houses; Each these lines contains both floating point number s x and y ( -200 <= x, y <=), the coordinates of a House in meters. All houses is at different positions.

A blank line follows the case. A line with n = 0 Indicates the end of the input;

Output

For each test case, print, numbers in a line separated by a space:the coordinate x of the meeting point o n the line y = 0 That minimizes the time of the last child arrives, and this time itself (measured in seconds AF ter midnight). Your answer should is accurate to within an absolute or relative error of 10-5.

Sample Input
21.5 1.53 010 041 44 4-3 32 454 7-4 07-6-2 48-50
Sample Output
1.500000000 1.5000000000.000000000 0.0000000001.000000000 5.0000000003.136363636 7.136363636

The main idea: there are n people to go back to a gathering point on X, ask everyone to return to the point of the shortest time.
Problem-solving ideas: Using three points to find the X-point coordinate, and finally find the furthest point to the distance of the point.


#include <bits/stdc++.h>using namespace std;struct cor{double x, y;} COR[55000]; #define MID (L+r)/2.0#define mid_l (mid+l)/2.0const double eps=1e-10;const double inf=1e9;int n;double Dis ( Cor A,cor b) {return (a.x-b.x) * (a.x-b.x) + (A.Y-B.Y) * (A.Y-B.Y);}    Double Calcu (double tx) {double ret=-inf;    Cor Tmp_;    tmp_.x=tx,tmp_.y=0;        for (int i=0;i<n;i++) {if (Ret<dis (COR[I],TMP_)) {Ret=dis (COR[I],TMP_); }} return sqrt (ret);}        Double Three_div (double l,double R) {while (r-l>eps) {if (CALCU (mid) >calcu (mid_l)) {r=mid;        }else{l=mid_l; }} return mid;} int main () {while (scanf ("%d", &n)!=eof&&n) {for (int i=0;i<n;i++) {scanf ("%lf%lf", &c        OR[I].X,&AMP;COR[I].Y);        } double Ans_x,ans_d;        ans_x= Three_div ( -200000.0,200000.0);        ANS_D=CALCU (ans_x);    printf ("%.9lf%.9lf\n", ans_x,ans_d); } return 0;}

  

BNU 4260--trick or Treat —————— "three-point parabola vertex"

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.