火柴人勇者试炼图片:急求C\C++高手解题

来源:百度文库 编辑:杭州交通信息网 时间:2024/04/17 03:40:32
最小的圆

Time Limit:5000MS Memory Limit:65536K
Total Submit:1 Accepted:0

Description

You are to write a program to find a circle which covers a set of points and has the minimal area. There will be no more than 100 points in one problem.

Input

The input contains several problems. The first line of each problem is a line containing only one integer N which indicates the number of points to be covered. The next N lines contain N points. Each point is represented by x and y coordinates separated by a space. After the last problem, there will be a line contains only a zero.

Output

For each input problem, you should give a one-line answer which contains three numbers separated by spaces. The first two numbers indicate the x and y coordinates of the result circle, and the third number is the radius of the circle. (use escape sequence %.2f)

Sample Input

2
0.0 0.0
3 0
5
0 0
0 1
1 0
1 1
2 2
0

Sample Output

1.50 0.00 1.50
1.00 1.00 1.41

大体意思是:输入几个坐标,找到一个最小的圆,包含这几个坐标,输出圆的圆心坐标和半径。

核心算法如下:
1.选取这些点中的几个点,要求如下:a.这些点连接而成的多边型能将所有点包含在内,b.点的个数最少,c.多边形为凸多边形
2.抛弃其他点,根据所选出来的几个点画圆,使圆的半径最小,且所有这几个点都在圆内.

挺难的,不知道有没有什么特定的算法。