Breaking Biscuits(模板题-求凸边形的宽)
Breaking Biscuits
时间限制: 1 Sec 内存限制: 128 MB Special Judge
提交: 70 解决: 26
[提交] [状态] [讨论版] [命题人:admin]
题目描述
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.
输入
• 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.
输出
样例输入
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(模板题-求凸边形的宽)的更多相关文章
- (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 ...
- 后缀数组(模板题) - 求最长公共子串 - poj 2774 Long Long Message
Language: Default Long Long Message Time Limit: 4000MS Memory Limit: 131072K Total Submissions: 21 ...
- UVA 796 Critical Links(模板题)(无向图求桥)
<题目链接> 题目大意: 无向连通图求桥,并将桥按顺序输出. 解题分析: 无向图求桥的模板题,下面用了kuangbin的模板. #include <cstdio> #inclu ...
- UVA 315 Network (模板题)(无向图求割点)
<题目链接> 题目大意: 给出一个无向图,求出其中的割点数量. 解题分析: 无向图求割点模板题. 一个顶点u是割点,当且仅当满足 (1) u为树根,且u有多于一个子树. (2) u不为树根 ...
- hdu1115 Lifting the Stone(几何,求多边形重心模板题)
转载请注明出处:http://blog.csdn.net/u012860063 题目链接:pid=1115">http://acm.hdu.edu.cn/showproblem.php ...
- luogu P4725 多项式对数函数 (模板题、FFT、多项式求逆、求导和积分)
手动博客搬家: 本文发表于20181125 13:25:03, 原地址https://blog.csdn.net/suncongbo/article/details/84487306 题目链接: ht ...
- POJ2774 & 后缀数组模板题
题意: 求两个字符串的LCP SOL: 模板题.连一起搞一搞就好了...主要是记录一下做(sha)题(bi)过程心(cao)得(dan)体(xin)会(qing) 后缀数组概念...还算是简单的,过程 ...
- HDU-3549 最大流模板题
1.HDU-3549 Flow Problem 2.链接:http://acm.hdu.edu.cn/showproblem.php?pid=3549 3.总结:模板题,参考了 http://ww ...
- POJ 3041 匈牙利算法模板题
一开始预习是百度的算法 然后学习了一下 然后找到了学长的ppt 又学习了一下.. 发现..居然不一样... 找了模板题试了试..百度的不好用 反正就是wa了..果然还是应当跟着学长混.. 图两边的点分 ...
随机推荐
- 技巧:开启ubuntu系统桌面上的右键进入terminal命令行控制台功能
$ sudo apt-get install nautilus-open-terminal 执行上述命令,重启. 重启命令: $ sudo reboot 注意:需要联网
- my06_sysbench install for mysql 并初始化表数据
sysbench安装 ************************************************************** 安装sysbench依赖包 rpm -q autom ...
- Linux Vi/Vim 在插入模式下键盘右边数字键输入异常
问题:Linux在 Vi/Vim 在编辑文件时遇到一个问题,当我在 Insert 模式下进行修改文件内容的时候,用到了键盘(104键,右边带数字键那种)进行数字输入,当我输入数字 “5” 时,插入的数 ...
- REQUIRED与REQUIRED_NEW
出处: https://blog.csdn.net/selfsojourner/article/details/74561745 spring 事务的传播行为中,有两个容易混淆的行为:REQUIRED ...
- io基础(字节流、字符流、转换流、缓冲字符流)
首先需要明确的一点是输入流输出流的输入输出是站在内存的角度看的,读取文件,把文件内容写到内存中,是输入流:写文件,把内存中的数据写到文件中,是输出流. IO操作主要有4个抽象类: 字节输入输出流:In ...
- 搜索提示(search suggest)文献阅读
Learning to Personalize Query Auto-Completion 样本 正例用用户的sug点击,其余是负例 特征 用户历史特征: query历史频次,候选和用户历史输入的ng ...
- Java基础11-数组
1.使用数组步骤: (1)声明数组 int[] a; (2)分配空间 a=new int[5]; (3)赋值 a[0]=1; int类型数组如果没有赋值,默认值为0,String类型数组默认为nul ...
- 性能测试工具LoadRunner06-LR之Virtual User Generator 事务(Transaction)
定义 为了衡量某个操作的性能,需要在操作的开始和结束位置插入这样一个范围,这就定义了一个transaction. 原因 从性能测试的角度出发,我们需要知道不同的操作所花费的时间,这样就能衡量不同的操作 ...
- MySQL 8.0之后版本密码修改
MySQL刚刚安装完毕时 mysqld --initialize grep password /var/log/mysqld.log 获取临时密码 mysql -uroot -p 输入临时密码登录My ...
- pacman usage
pacman使用 安装了系统时候, 应该立马使用pacman-mirrors -c China更新源, 再使用pacman -Syyn更新系统 编辑/etc/pacman.conf添加 [archli ...