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 ...
随机推荐
- Android BuildConfig.DEBUG的妙用
在Android开发中,我们使用android.util.Log来打印日志,方便我们的开发调试.但是这些代码不想在发布后执行,我们并不想在软件发布后调试日志被其他开发者看到,现在我的方法是设置一个全局 ...
- 登录数据库后,use db很慢的问题
mysql> use dbl Reading table information for completion of table and column names You can turn of ...
- asp的RegExp对象正则表达式功能用法
RegExp对象提供简单的正则表达式支持功能. RegExp对象的用法: 以下为引用的内容: Function RegExpTest(patrn, strng) Dim regEx, Match, M ...
- 8.4 sikuli 集成进eclipse 报错:Unsupported major.minor version 51.0
8.3中的问题Win32Util.dll: Can't load 32-bit .dll on a AMD 64 bit platform 解决之后,执行还是会有报错:Unsupported maj ...
- Jquery 实现原理之 Ajax
一:Jquery Ajax底层接口有:$.ajaxPrefilters.$.ajaxTransport.$.ajaxSettings.$ajaxSetup.$ajaxSettings; 其中$.aja ...
- iOS xcode工程了解
一个xcode工程默认是在一个主线程的,有需要可以创建分线程 判断是否是主线程: NSThread *thread1=[NSThread currentThread]; if ([red isMain ...
- linux(视频学习)2
第二部分(javaee的开发环境的搭建): 1. 安装jdk的过程: 安装ios的镜像文件,挂载到/mnt目录下.挂载: mount /mnt/cdrom卸载: umount /mnt/cdrom ...
- gameUnity 0.2 网络游戏框架(计划)
能说的就是 请大家都耐心等待,不做国产垃圾,只追求国外经典,这就是 这套框架未来的发展 一:2d 3d场景融合 人物移动 2d 3d 层 移动 有差值(共6层,2d天空层.前景3d物体层有 景深), ...
- C语言EOF
验证表达式getchar()!=EOF的值是1还是0 编写一个打印EOF值的程序 windows下是ctrl-z 就是ctrl和z一起按了,就是结束符linux下是ctrl-d是结束符.这个是一个 ...
- 交换数组中两个元素的位置,元素包括key和value 一维数组
/*author: yangyu@sina.cndescription: 交换数组中两个元素的位置,元素包括key和value,具体用法见下面的例子*/$arr = array(11=>'a', ...