Hdu 3932 Groundhog Build Home

Source: Internet
Author: User
Tags integer numbers

Groundhog Build Home

Time limit:15000/5000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): 2647 Accepted Submission (s): 1074


Problem Descriptiongroundhogs was good at digging holes, their home is a hole, usually a group of Groundhogs would find a M Ore suitable area for their activities and build their home at the this area. Xiaomi have grown up, can no longer live with its Parents.so it needs to build their own home.xiaomi like to visit other family so much, at all visit it always start from t He point's own home. Xiaomi would visit all of the Groundhogs ' home on this area (it would chose the linear distance between). To save Energy,xiaomi would what do you-to-do it find where its home built,so that the longest distance between Xiaomi ' s Ho Me and the other groundhog's home is minimum.

Inputthe input consists of many test cases,ending of EOF. Each test case is begins with a line containing three integers X, Y, N separated by space. The numbers satisfy conditions:1 <= x, y <=10000, 1 <= n<= 1000. Groundhogs acivity at a rectangular area, and X, Y is the of the side of this rectangle, the number N stands for the number O F holes. Then exactly N lines follow, each containing the integer numbers XI and yi (0 <= Xi <= X, 0 <= yi <= Y) indica Ting the coordinates of one home.

Outputprint exactly the lines for each test case. The first line was the coordinate of Xiaomi ' s home which we help to find. The second line is he longest distance between Xiaomi's home and the other groundhog ' s home. The output round to the nearest number with exactly one digit after the decimal point (0.05 rounds up to 0.1).

Sample Input1000 50 110 101000 50 40 01 00 11 1

Sample Output (10.0,10.0). 0.0 (0.5,0.5). 0.7

Source2011 multi-university Training Contest 10-host by Hrbeu

Recommendwe has carefully selected several similar problems for you:3935 3934 3936 3931 3933 Test instructions: A point that requires a minimum maximum distance to a given n point, and a point limit Within a given rectangle, corresponding to the minimum point coverage of the mathematical model.

Consider the case of covering three points first, in two cases:

①: Three points are on a circle, the circle is the circumscribed circle of the triangle

②: Two points on a circle, the third point in the circle, and the line between two points on the circle must be a diameter

If it's multiple circles, iterate over and over.

One thing that matters is the circumscribed circle of the law, the theft diagram illustrates:

A slip of proof from ZJK God

#include <cstdio>#include<cstdlib>#include<ctime>#include<cmath>#include<algorithm>#definePF (x) ((x) * (x))using namespacestd;Const intn=1e5+1;Const Doubleeps=1e-7;structnode{Doublex, y; voidInput () {scanf ("%LF%LF",&x,&y);}} P[n],c;intN,x,y;DoubleR;DoubleGet_dis (ConstNode &a,ConstNode &b) {    returnsqrt (PF (a.x-b.x) +PF (a.y-b.y));} Node Get_focus (ConstNode &a,ConstNode &b,ConstNode &c)    {node T; Doublec1= (A.X*A.X-B.X*B.X+A.Y*A.Y-B.Y*B.Y)/2.0; DoubleC2= (C.X*C.X-B.X*B.X+C.Y*C.Y-B.Y*B.Y)/2.0; T.x= (c1* (c.y-b.y)-c2* (A.Y-B.Y))/((a.x-b.x) * (C.Y-B.Y)-(c.x-b.x) * (a.y-b.y)); T.y= (c1* (c.x-b.x)-c2* (a.x-b.x))/((A.Y-B.Y) * (c.x-b.x)-(C.Y-B.Y) * (a.x-b.x)); returnt;}voidWork () {random_shuffle (P+1, p+n+1); C=p[1];r=0;  for(intI=2; i<=n;i++){        if(Get_dis (P[I],C) +eps>R) {C=p[i];r=0;  for(intj=1; j<i;j++){                if(Get_dis (P[J],C) +eps>R) {c.x= (p[i].x+p[j].x)/2; C.y= (P[I].Y+P[J].Y)/2; R=Get_dis (C,p[j]);  for(intk=1; k<j;k++){                        if(Get_dis (P[K],C) +eps>R) {C=Get_focus (P[i],p[j],p[k]); R=Get_dis (C,p[k]); } }}}}} printf ("(%.1LF,%.1LF). \n%.1lf\n", c.x,c.y,r);}intMain () {Srand (0));  while(SCANF ("%d%d%d", &x,&y,&n) = =3){         for(intI=1; i<=n;i++) P[i].input ();    Work (); }     return 0;}

Hdu 3932 Groundhog Build Home

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.