程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> C++入門知識 >> HDOJ 2215 Maple trees ×îСԲ¸²¸Ç

HDOJ 2215 Maple trees ×îСԲ¸²¸Ç

編輯:C++入門知識

HDOJ 2215 Maple trees ×îСԲ¸²¸Ç



ÔöÁ¿·¨×îСԲ¸²¸Ç....


Maple trees

Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1646 Accepted Submission(s): 510


Problem Description There are a lot of trees in HDU. Kiki want to surround all the trees with the minimal required length of the rope . As follow,
\

To make this problem more simple, consider all the trees are circles in a plate. The diameter of all the trees are the same (the diameter of a tree is 1 unit). Kiki can calculate the minimal length of the rZ†·Ÿ"http://www.Bkjia.com/kf/ware/vc/" target="_blank" class="keylink">vcGUgLCBiZWNhdXNlIGl0"s so easy for this smart girl.
But we don't have a rope to surround the trees. Instead, we only have some circle rings of different radius. Now I want to know the minimal required radius of the circle ring. And I don't want to ask her this problem, because she is busy preparing for the examination.
As a smart ACMer, can you help me ?
\

Input The input contains one or more data sets. At first line of each input data set is number of trees in this data set n £¨1 <= n <= 100£©, it is followed by n coordinates of the trees. Each coordinate is a pair of integers, and each integer is in [-1000, 1000], it means the position of a tree¡¯s center. Each pair is separated by blank.
Zero at line for number of trees terminates the input for your program.
Output Minimal required radius of the circle ring I have to choose. The precision should be 10^-2.
Sample Input
2
1 0
-1 0
0

Sample Output
1.50

Author zjt


/* ***********************************************
Author        :CKboss
Created Time  :2014Äê12ÔÂ29ÈÕ ÐÇÆÚÒ» 17ʱ19·Ö19Ãë
File Name     :HDOJ2215.cpp
************************************************ */

#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

using namespace std;

const int maxn = 111;

const double eps=1e-8;

int dcmp(double x)
{
	if(fabs(x)eps?1:-1;
}

struct Point
{
	double x,y;
	Point(){}
	Point(double _x,double _y) { x=_x; y=_y;}
}pt[maxn];

struct Circle
{
	Point c; double r;
	Circle(){}
	Circle(Point _c,double _r) { c=_c; r=_r; }
};

Point operator+(Point A,Point B) { return Point(A.x+B.x,A.y+B.y); }
Point operator-(Point A,Point B) { return Point(A.x-B.x,A.y-B.y); }
Point operator*(Point A,double p) { return Point(A.x*p,A.y*p); }
Point operator/(Point A,double p) { return Point(A.x/p,A.y/p); }

double Dot(Point A,Point B) { return A.x*B.x+A.y*B.y; }
double Length(Point A) { return sqrt(Dot(A,A)); }
double Cross(Point A,Point B) { return A.x*B.y-A.y*B.x; }

Circle CircumscribedCircle(Point p1,Point p2,Point p3)
{
	double Bx=p2.x-p1.x,By=p2.y-p1.y;
	double Cx=p3.x-p1.x,Cy=p3.y-p1.y;
	double D=2*(Bx*Cy-By*Cx);
	double cx=(Cy*(Bx*Bx+By*By)-By*(Cx*Cx+Cy*Cy))/D+p1.x;
	double cy=(Bx*(Cx*Cx+Cy*Cy)-Cx*(Bx*Bx+By*By))/D+p1.y;
	Point p=Point(cx,cy);
	return Circle(p,Length(p1-p));
}

void min_cover_circle(Point p[],int n,Circle& c)
{
	c.c=p[0]; c.r=0;
	for(int i=1;i0)
		{
			c.c=p[i]; c.r=0;
			for(int j=0;j0)
				{
					c.c=Point((p[i].x+p[j].x)/2.,(p[i].y+p[j].y)/2.);
					c.r=Length(p[j]-p[i])/2.;
					for(int k=0;k0)
						{
							c=CircumscribedCircle(p[i],p[j],p[k]);
						}
					}
				}
			}
		}
	}
}

int n;

int main()
{
    //freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

	while(scanf("%d",&n)!=EOF&&n)
	{
		for(int i=0;i

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved