POJ1113翻译 围墙

围墙

题目描述

http://poj.org/problem?id=1113

很久以前有一个吝啬的国王,他命令自己的首席建筑师围绕城堡建造一圈围墙。这位国王十分贪婪,所以他绝对不会听取建筑师的意见去建造那种外观靓丽还有很多高塔的豪华围墙,他只想用最少的石头和劳工完成;并且国王觉得围墙与城堡的距离不能小于一个确定的值。如果建筑师建造围墙时消耗的资源比国王的预算多,那他立刻就要人头落地。现在国王向建筑师要求一份建筑方案(贪婪的国王只在乎资源消耗,所以方案的内容只需要有资源预算即可)。


可怜的建筑师需要你帮助他保住脑袋。你只需要写一个程序,计算出要满足国王的要求所需的最短围墙长度即可。

为了简化问题,假定国王的城堡是一个平面上的多边形。建筑师已经建好了一个直角坐标系,并且步量了城堡每个顶点的位置。


输入

输入文件第一行包含两个用空格隔开的整数N和L.  N为国王多边形城堡的顶点数量, L是国王允许的围墙到城堡距离的最小值.

(3 <= N <= 1000)       (1 <= L <= 1000)

接下来N行, 以顺时针方向描述顶点.  每行包含两个整数Xi,Yi(-10000 <= Xi,Yi <= 10000), 代表顶点在直角坐标系中的坐标. 输入保证顶点不相同, 且城堡多边形的边只在输入的顶点处相交.


输出

输出能满足国王要求的围墙的最小长度. 你必须用步表示, 因为小数那时候还没发明. 由于国王不能容忍过大的误差, 所以长度必须精确到8英寸(1步计为12英寸).

(注:好像对计算结果直接四舍五入就行了....)


样例输入

9 100
200 400
300 400
300 300
400 300
400 400
500 400
500 200
350 200
200 200

样例输出

1628

Description

Once upon a time there was a greedy King who ordered his chief Architect to build a wall around the King's castle. The King was so greedy, that he would not listen to his Architect's proposals to build a beautiful brick wall with a perfect shape and nice tall towers. Instead, he ordered to build the wall around the whole castle using the least amount of stone and labor, but demanded that the wall should not come closer to the castle than a certain distance. If the King finds that the Architect has used more resources to build the wall than it was absolutely necessary to satisfy those requirements, then the Architect will loose his head. Moreover, he demanded Architect to introduce at once a plan of the wall listing the exact amount of resources that are needed to build the wall. 

Your task is to help poor Architect to save his head, by writing a program that will find the minimum possible length of the wall that he could build around the castle to satisfy King's requirements. 

The task is somewhat simplified by the fact, that the King's castle has a polygonal shape and is situated on a flat ground. The Architect has already established a Cartesian coordinate system and has precisely measured the coordinates of all castle's vertices in feet.

Input

The first line of the input file contains two integer numbers N and L separated by a space. N (3 <= N <= 1000) is the number of vertices in the King's castle, and L (1 <= L <= 1000) is the minimal number of feet that King allows for the wall to come close to the castle. 

Next N lines describe coordinates of castle's vertices in a clockwise order. Each line contains two integer numbers Xi and Yi separated by a space (-10000 <= Xi, Yi <= 10000) that represent the coordinates of ith vertex. All vertices are different and the sides of the castle do not intersect anywhere except for vertices.

Output

Write to the output file the single number that represents the minimal possible length of the wall in feet that could be built around the castle to satisfy King's requirements. You must present the integer number of feet to the King, because the floating numbers are not invented yet. However, you must round the result in such a way, that it is accurate to 8 inches (1 foot is equal to 12 inches), since the King will not tolerate larger error in the estimates.

Sample Input

9 100
200 400
300 400
300 300
400 300
400 400
500 400
500 200
350 200
200 200

Sample Output

1628

Hint

结果四舍五入就可以了





猜你喜欢

转载自blog.csdn.net/Lytning/article/details/24046075