Breaking Biscuits

时间限制: 1 Sec  内存限制: 128 MB  Special Judge
提交: 70  解决: 26
[提交] [状态] [讨论版] [命题人:admin]

题目描述

This year, Walter’s workplace resolved to try something radically different: they’re going to change the weekly order of biscuits for the break room to a whole other brand.
Biscuits come in many shapes and sizes, but the particular brand they settled on has two special qualities:
• It is completely planar (two-dimensional);
• It is perfectly polygon-shaped.
However, disaster struck immediately: the available mugs in the break room are too narrow for Walter to be able to dunk these new biscuits into, no matter what combination of rotations along the three axes he tries.
There is only one thing for it: Walter will need to order another mug.
Before taking this drastic step, it is vital to know how wide the diameter of this mug will need to be in order to succesfully accommodate a (possibly rotated) biscuit of the new brand.

 

输入

• One line containing an integer N (3 ≤ N ≤ 100), the number of vertices in the biscuit.
• Each of the following N lines contains two space-separated integers Xi and Yi (−105 ≤Xi, Yi ≤ 105), the coordinates of the i-th vertex.
Vertices are always given in anti-clockwise order. Also, as anyone can tell you, biscuits never self-intersect and always have positive area.

输出

Output the minimum possible diameter of the new mug, in order that it can fit the new kind of biscuit fully inside in at least one orientation. The output must be accurate to an absolute or relative error of at most 10−6.

 

样例输入

4
0 0
5 0
5 2
0 2

样例输出

2.0
 #include<bits/stdc++.h>
using namespace std;
const int N=;
int n;
double ans=1e100;
struct P
{
int x,y;
P() {}
P(int _x,int _y)
{
x=_x,y=_y;
}
P operator-(P b)
{
return P(x-b.x,y-b.y);
}
double len()
{
return hypot(x,y);
}
} a[N];
double cross(P a,P b)
{
return a.x*b.y-a.y*b.x;
}
double dist(P p,P a,P b)
{
return cross(p-a,b-a)/(b-a).len();
}
void solve()
{
for(int i = ; i <= n; i++)
{
for(int j = ; j < i; j++)
{
double l=1e100,r=-1e100;
for(int k = ; k <= n; k++)
{
l=min(l,dist(a[k],a[i],a[j]));
r=max(r,dist(a[k],a[i],a[j]));
}
r-=l;
ans=min(ans,r);
}
}
}
int main()
{
scanf("%d",&n);
for(int i=; i<=n; i++) scanf("%d %d",&a[i].x,&a[i].y);
solve();
printf("%.10f\n",ans);
return ;
}

最新文章

  1. Redis时延问题分析及应对
  2. javadoc 生成自定义的标签
  3. Atitit 表达式原理 语法分析&#160;原理与实践 解析java的dsl &#160;递归下降是现阶段主流的语法分析方法
  4. qau-国庆七天乐——B
  5. HDU 4944 FSF’s game 一道好题
  6. el 和 fmt 常用
  7. ASP.NET中的Eval与DataBinder.Eval()方法
  8. Labview二进制文件的操作
  9. CSS圆角,输入框提示信息,JS查找同级元素
  10. 通知角标(2)只用一个TextView实现
  11. hdu 5650 so easy (异或)
  12. Counting Triangles(hd1396)
  13. 05JS高级 方法没有块级作用域
  14. 聊聊单元測试(一)——EasyMock
  15. 认识ExtJS(05)--
  16. C# 泛型集合
  17. Reachability from the Capital CodeForces - 999E (强连通)
  18. python(list、字典、元组、字符串方法、文件读写)草稿
  19. 【机器学习_7】numpy
  20. 用C#学习数据结构之线性表

热门文章

  1. my04_Mysql复制数据一致性校验
  2. 在Oracle创建一个自己用的用户及角色
  3. js学习笔记 -- Promise
  4. APP测试总结2
  5. getopt 学习
  6. Nginx的验证、启动、停止、重启
  7. c3p0 数据连接池 流行开源
  8. JetBrains IDE激活
  9. 2019.3.26判断是否回文(java实现)
  10. div的浮动(float)