博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ 1113 Wall 凸包
阅读量:6345 次
发布时间:2019-06-22

本文共 3405 字,大约阅读时间需要 11 分钟。

Wall
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 29183   Accepted: 9768

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 100200 400300 400300 300400 300400 400500 400500 200350 200200 200

Sample Output

1628

#include
#include
#include
#include
using namespace std;struct node{ double x,y;}a[1005],b[1005];double cmp(node n,node m){ if(n.x != m.x) return n.x < m.x; else return n.y < m.y;}double Cross(node a,node b,node c){ return (b.x-a.x)*(c.y-a.y)-(c.x-a.x)*(b.y-a.y);}double dis(node a,node b){ return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}int CH(node* a,int n,node* b){ sort(a,a+n,cmp); int m=0,i; for(i=0;i
1 && Cross(b[m-2],b[m-1],a[i]) < 0) m--; b[m++]=a[i]; } int k=m; for(i=n-2;i>=0;i--) { while(m > k && Cross(b[m-2],b[m-1],a[i]) < 0) m--; b[m++]=a[i]; } if(n >1) m--; return m;}int main(){ int n,m; while(cin>>n>>m) { if(n==0) break; memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); int i,j; for(i=0;i
>a[i].x>>a[i].y; } int k=CH(a,n,b); double s=0; for(i=1;i

转载地址:http://wmcla.baihongyu.com/

你可能感兴趣的文章
秋名山老司机(详解)——bugku
查看>>
RED | Robot Framework集成开发环境
查看>>
育碧同 Mozilla 联手开发 AI 代码助手
查看>>
【实用】面对枯燥的源码,如何才能看得下去?
查看>>
智库说 | 徐远:数字时代的城市潜力
查看>>
《JSP极简教程》jsp c:forEach用法
查看>>
WebSocket详解(六):刨根问底WebSocket与Socket的关系
查看>>
用 Go 写一个轻量级的 ssh 批量操作工具
查看>>
网站设计之合理架构CSS 架构CSS
查看>>
OTP 22.0 RC3 发布,Erlang 编写的应用服务器
查看>>
D语言/DLang 2.085.1 发布,修复性迭代
查看>>
感觉JVM的默认异常处理不够好,既然不好那我们就自己来处理异常呗!那么如何自己处理异常呢?...
查看>>
Java 基础 之 算数运算符
查看>>
Windows下配置安装Git(二)
查看>>
一个最简单的基于Android SearchView的搜索框
查看>>
铁路开通WiFi“钱景”不明
查看>>
Nutanix领衔的超融合能带来新存储黄金时代吗?
查看>>
Facebook申请专利 或让好友及陌生人相互拼车
查看>>
电力“十三五”规划:地面光伏与分布式的分水岭
查看>>
美联社再告FBI:要求公开请黑客解锁iPhone花费
查看>>