题目
There are a lot of trees in an area. A peasant wants to buy a rope to surround all these trees. So at first he must know the minimal required length of the rope. However, he does not know how to calculate it. Can you help him?
The diameter and length of the trees are omitted, which means a tree can be seen as a point. The thickness of the rope is also omitted which means a rope can be seen as a line.
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, it is followed by series of coordinates of the trees. Each coordinate is a positive integer pair, and each integer is less than 32767. Each pair is separated by blank.
Zero at line for number of trees terminates the input for your program.
Output
The minimal length of the rope. The precision should be 10^-2.
Sample Input
9
12 7
24 9
30 5
41 9
80 7
50 87
22 9
45 1
50 7
0
Sample Output
243.06
意思
就是在平面给你一组点集,让你求出周长最小的多边形可以包围住全部的点。
题目翻译为给你一个区域的树,问买多长的绳子可以将它们包围起来。
思路
此题标准解法为求凸包,求出凸包后,然后求这些点之间的距离之和即为所需绳子的长度。下面简单解释下概念。
相关概念
凸包
严格的数学证明为:在一个实数向量空间V中,对于给定集合X,所有包含X的凸集的交集S被称为X的凸包。
所谓凸集,就是对于集合中任意两点x,y,若存在a属于[0,1],ax + (1 - a)y 还属于这个集合,即任意两点的线段上的点也属于这个集合,这个集合就是凸集。
我们还可以将凸包映射到几何上去理解,在一个二维平面,凸包可以想象为一个刚好包含所有点的橡皮圈。计算凸包其实就是计算求的外围(蓝线)上的点。
向量积
向量积又称