CodeForces 614C Peter and Snow Blower
简单计算几何,只要算出圆心到多边形上的最短距离和最长距离即可
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std; const int maxn=+;
struct Point
{
double x,y;
} p[maxn];
double a,b;
int n; double GetPointDistance(Point p1, Point p2)
{
return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
} double GetNearestDistance(Point PA, Point PB, Point P3)
{
double a,b,c;
a=GetPointDistance(PB,P3);
if(a<=0.00001) return 0.0f;
b=GetPointDistance(PA,P3);
if(b<=0.00001) return 0.0f;
c=GetPointDistance(PA,PB);
if(c<=0.00001) return a;
if(a*a>=b*b+c*c) return b;
if(b*b>=a*a+c*c) return a;
double l=(a+b+c)/;
double s=sqrt(l*(l-a)*(l-b)*(l-c));
return *s/c;
} int main()
{
double Max=-;
double Min=-;
scanf("%d%lf%lf",&n,&a,&b);
Point T;
T.x=a;
T.y=b;
for(int i=; i<n; i++) scanf("%lf%lf",&p[i].x,&p[i].y);
for(int i=; i<n; i++)
{
double MinLen=GetNearestDistance(p[(i+)%n],p[i],T);
if(Min==-) Min=MinLen;
else Min=min(Min,MinLen); double Len1=sqrt((p[i].x-a)*(p[i].x-a)+(p[i].y-b)*(p[i].y-b));
double Len2=sqrt((p[(i+)%n].x-a)*(p[(i+)%n].x-a)+(p[(i+)%n].y-b)*(p[(i+)%n].y-b));
double MaxLen=max(Len1,Len2);
if(Max==-) Max=MaxLen;
else Max=max(Max,MaxLen);
} printf("%lf\n",3.1415926*(Max*Max-Min*Min));
return ;
}
CodeForces 614C Peter and Snow Blower的更多相关文章
- codeforces 613A. Peter and Snow Blower
题目链接 给一个多边形, 一个多边形外的定点, 求这个点距离多边形的最短距离和最长距离. 最长距离肯定是和某个顶点的连线, 而最短距离是和点的连线或是和某条边的连线. 对于一条边上的两个点a, b, ...
- [CodeForces - 614C] C - Peter and Snow Blower
C - Peter and Snow Blower Peter got a new snow blower as a New Year present. Of course, Peter decide ...
- Codeforces Round #339 (Div. 1) A. Peter and Snow Blower 计算几何
A. Peter and Snow Blower 题目连接: http://www.codeforces.com/contest/613/problem/A Description Peter got ...
- codeforce #339(div2)C Peter and Snow Blower
Peter and Snow Blower 题意:有n(3 <= n <= 100 000)个点的一个多边形,这个多边形绕一个顶点转动,问扫过的面积为多少? 思路:开始就认为是一个凸包的问 ...
- A. Peter and Snow Blower 解析(思維、幾何)
Codeforce 613 A. Peter and Snow Blower 解析(思維.幾何) 今天我們來看看CF613A 題目連結 題目 給你一個點\(P\)和\(n\)個點形成的多邊形(照順或逆 ...
- 【14.36%】【codeforces 614C】Peter and Snow Blower
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- Codeforces Round #339 Div.2 C - Peter and Snow Blower
Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. A ...
- 【CodeForces 613A】Peter and Snow Blower
题 题意 给出原点(不是(0,0)那个原点)的坐标和一个多边形的顶点坐标,求多边形绕原点转一圈扫过的面积(每个顶点到原点距离保持不变). 分析 多边形到原点的最小距离和最大距离构成的两个圆之间的圆环就 ...
- Peter and Snow Blower CodeForces - 613A (点到线段距离)
大意: 给定多边形, 给定点$P$, 求一个以$P$为圆心的最小的圆环包含整个多边形. #include <iostream> #include <cmath> #define ...
随机推荐
- Linux系统的时区和时间调整
linux调整系统时区: 1)tzselect命令 找到相应的时区文件/usr/share/zoneinfo/Asia/Shanghai,用这个文件替换当前的/etc/localtime文件. 或者 ...
- Learn about images & containers
Learn about images & containers Docker Engine provides the core Docker technology that enables i ...
- C#抓取页面时候,获取页面跳转后的地址
static string fanhuiurl(string cahxunurl) { string url = ""; HttpWebRequest req = (HttpWeb ...
- 基于Win32 SDK实现的一个简易线程池
利用C++实现了一个简易的线程池模型(基于Win32 SDK),方便使用多线程处理任务.共包含Thread.h.Thread.cpp.ThreadPool.h.ThreadPool.cpp四个源文件. ...
- Toolbar Painter 工具条制作
工具条制作工具(ToolBarPainter2013.exe),专为程序猿设计,界面开发必备.当用VC编程制作工具条时,需要为工具栏上每一个button添加图标,是一件极其繁琐的事情,该工具可利用已有 ...
- 转 如何不耍流氓的做运维之——SHELL脚本
家都是文明人,尤其是做运维的,那叫一个斯文啊.怎么能耍流氓呢?赶紧看看,编写 SHELL 脚本如何能够不耍流氓. 下面的案例,我们以 MySQL 数据库备份 SHELL 脚本的案例来进行阐述. 不记录 ...
- String s = new String("aa") 创建了几个对象?
1 最近几个同学面试的时候出现了这样一个问题 刚听到这个题目的时候的确是不知所措: 经过网上的查找和自己的理解来解释一下这个题目的答案 答案是: 为什么呢??? 1 实现我们都知道创建实例有两种方法 ...
- java设计模式案例详解:工厂模式
1.简单工厂模式 在不考虑扩展的情况下还是很好用的,其实我们写代码也很经常用到,其主要理解在于传入不同参数则构建不同对象,只有一个工厂,如需添加产品涉及到扩展需要修改比较多的东西,不符合开闭原则,如下 ...
- preg_replace 方法
标红关键字 $text = "Sample sentence from KomunitasWeb, regex has become popular in web programming. ...
- git 强制覆盖本地文件
git fetch --all git reset --hard origin/master git pull