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 ;
}

Breaking Biscuits(模板题-求凸边形的宽)的更多相关文章

  1. (hdu step 7.2.1)The Euler function(欧拉函数模板题——求phi[a]到phi[b]的和)

    题目: The Euler function Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...

  2. 后缀数组(模板题) - 求最长公共子串 - poj 2774 Long Long Message

    Language: Default Long Long Message Time Limit: 4000MS   Memory Limit: 131072K Total Submissions: 21 ...

  3. UVA 796 Critical Links(模板题)(无向图求桥)

    <题目链接> 题目大意: 无向连通图求桥,并将桥按顺序输出. 解题分析: 无向图求桥的模板题,下面用了kuangbin的模板. #include <cstdio> #inclu ...

  4. UVA 315 Network (模板题)(无向图求割点)

    <题目链接> 题目大意: 给出一个无向图,求出其中的割点数量. 解题分析: 无向图求割点模板题. 一个顶点u是割点,当且仅当满足 (1) u为树根,且u有多于一个子树. (2) u不为树根 ...

  5. hdu1115 Lifting the Stone(几何,求多边形重心模板题)

    转载请注明出处:http://blog.csdn.net/u012860063 题目链接:pid=1115">http://acm.hdu.edu.cn/showproblem.php ...

  6. luogu P4725 多项式对数函数 (模板题、FFT、多项式求逆、求导和积分)

    手动博客搬家: 本文发表于20181125 13:25:03, 原地址https://blog.csdn.net/suncongbo/article/details/84487306 题目链接: ht ...

  7. POJ2774 & 后缀数组模板题

    题意: 求两个字符串的LCP SOL: 模板题.连一起搞一搞就好了...主要是记录一下做(sha)题(bi)过程心(cao)得(dan)体(xin)会(qing) 后缀数组概念...还算是简单的,过程 ...

  8. HDU-3549 最大流模板题

    1.HDU-3549   Flow Problem 2.链接:http://acm.hdu.edu.cn/showproblem.php?pid=3549 3.总结:模板题,参考了 http://ww ...

  9. POJ 3041 匈牙利算法模板题

    一开始预习是百度的算法 然后学习了一下 然后找到了学长的ppt 又学习了一下.. 发现..居然不一样... 找了模板题试了试..百度的不好用 反正就是wa了..果然还是应当跟着学长混.. 图两边的点分 ...

随机推荐

  1. Problem05 判断分数等级

    题目:利用条件运算符的嵌套来完成此题:学习成绩>=90分的同学用A表示,60-89分之间的用B表示,60分以下的用C表示. 程序分析:(a>b)?a:b这是条件运算符的基本例子. impo ...

  2. my.赚钱

    http://mhxy.gamedog.cn/201503/999433.html   (发表于 2015-03-19) 梦幻西游手游四种赚钱技巧翻身做土豪教程,在游戏中玩家需要知道的就是赚钱方法是非 ...

  3. eclipse decompiler

    # eclipse -> help -> eclipse marketplace # decompiler

  4. 【C】一个读取文件记录器

    分享一下!!! #include<stdio.h> #include<windows.h> #define N 70000 //定义行数!!用空间换取时间 struct stu ...

  5. MAYA删除不干净

    AUTODESK系列软件着实令人头疼,安装失败之后不能完全卸载!!!(比如maya,cad,3dsmax等).有时手动删除注册表重装之后还是会出现各种问题,每个版本的C++Runtime和.NET f ...

  6. 牛客网Java刷题知识点之字符流缓冲区、BufferedWriter、BufferedReader、BufferedReader-readLine方法原理、自定义MyBufferedReader-read方法、自定义MyBufferedReader-readLine方法

    不多说,直接上干货! 把提高效率的动作,封装成一个对象.即把缓冲区封装成一个对象. 就是在一个类里封装一个数组,能对流锁操作数据进行缓存. 什么是字符流缓冲区? 善于使用字符流缓冲区,减轻负担,提高下 ...

  7. CI控制器调用内部方法并载入相应模板的做法

    当我打开链接:http://localhost/3g/index/open/a/b?from=timeline后,判断链接中的from是否等于timeline,如果等于timeline,那么就调用控制 ...

  8. 最新版本dede与discuz通过ucenter完美整合

    人合租虚拟主机.然后到相关的官方网站上面下载相关的程序,我下载的是DedeCmsV5.7-GBK+Discuz_X2_RC_SC_GBK+UCenter_1.6.0_SC_GBK这个程序组合.涉及到怎 ...

  9. OAuth2.0和企业内部统一登录,token验证方式,OAuth2.0的 Authorization code grant 和 Implicit grant区别

    统一登录是个很多应用系统都要考虑的问题,多个项目的话最好前期进行统一设计,否则后面改造兼容很麻烦: cas认证的方式:新公司都是老项目,用的是cas认证的方式,比较重而且依赖较多,winform的项目 ...

  10. Jquery 客户端验证

    Jquery 客户端验证 //引入js文件 validate.js <html> <head> <title>jqueryValidateDemo</titl ...