C - Peter and Snow Blower

Peter got a new snow blower as a New Year present. Of course, Peter decided to try it immediately. After reading the instructions he realized that it does not work like regular snow blowing machines. In order to make it work, you need to tie it to some point that it does not cover, and then switch it on. As a result it will go along a circle around this point and will remove all the snow from its path.

Formally, we assume that Peter's machine is a polygon on a plane. Then, after the machine is switched on, it will make a circle around the point to which Peter tied it (this point lies strictly outside the polygon). That is, each of the points lying within or on the border of the polygon will move along the circular trajectory, with the center of the circle at the point to which Peter tied his machine.

Peter decided to tie his car to point P and now he is wondering what is the area of ​​the region that will be cleared from snow. Help him.

Input

The first line of the input contains three integers — the number of vertices of the polygon n (), and coordinates of point P.

Each of the next n lines contains two integers — coordinates of the vertices of the polygon in the clockwise or counterclockwise order. It is guaranteed that no three consecutive vertices lie on a common straight line.

All the numbers in the input are integers that do not exceed 1 000 000 in their absolute value.

Output

Print a single real value number — the area of the region that will be cleared. Your answer will be considered correct if its absolute or relative error does not exceed 10 - 6.

Namely: let's assume that your answer is a, and the answer of the jury is b. The checker program will consider your answer correct, if .

Example

Input
3 0 00 1-1 21 2
Output
12.566370614359172464
Input
4 1 -10 01 22 01 1
Output
21.991148575128551812

Note

In the first sample snow will be removed from that area:

题目的意思是,给你n+1个点(其中一个是基准点(已知),且两两相异,且是按顺序给出),时围城的多边形绕基准点转一圈,求刷过的面积.

易得刷过面积=大圆面积-小圆面积=π*(r大*r大-r小*r小).

怎么确定r大?即为离基准点最远的点与基准点的距离.

怎么确定r小?有可能是基准点到某个点的距离,有可能是到某两点连线的线段的距离(注意是线段).

r大非常好算,r小就麻烦一点了.我们需要考虑基准点与每一对相邻点的关系.

我们需要分类讨论.

我们设基准点为x,两个相邻点为y,z,x与y距离为a,x与z距离为b,y与z距离为c.

如果a^2+c^2<b^2,则x到线段yz的距离为a(特殊的,相等的情况也包含);

如果b^2+c^2<a^2,则x到线段yz的距离为b(特殊的,相等的情况也包含);

其他情况,则为下图:

此时,x到yz的垂线在三角形内部,那么可以用海伦公式解决,先通过公式算出三角形面积,然后乘以2除以c就行了.

 #include<cstdio>
 #include<cstring>
 #include<algorithm>
 #include<cmath>
 using namespace std;
 ;
 const double PI=acos(-1.0);
 int n;
 double Mx,Mn;
 inline int read(){
     ,f=; char ch=getchar();
     '){if (ch=='-') f=-f; ch=getchar();}
     +ch-',ch=getchar();
     return x*f;
 }
 struct point{
     int x,y;
     void re(){x=read(),y=read();}
 }A[];
 double ds(point P,point Q){return sqrt((double)(P.x-Q.x)*(P.x-Q.x)+(double)(P.y-Q.y)*(P.y-Q.y));}
 int main(){
     n=read(),A[].re(),Mx=-,Mn=1e18;
     ; i<=n; i++) A[i].re(); A[n+]=A[];
     ; i<=n; i++){
         ]);
         ],A[]);
         ]);
         Mx=max(Mx,max(a,b));
         if (a*a+c*c<=b*b) Mn=min(Mn,a); else
         if (b*b+c*c<=a*a) Mn=min(Mn,b); else{
             double p=(a+b+c)/2.0,s=sqrt(p*(p-a)*(p-b)*(p-c));
             Mn=min(Mn,s*2.0/c);
         }
     }
     printf("%.15f",PI*(Mx*Mx-Mn*Mn));
     ;
 }

[CodeForces - 614C] C - Peter and Snow Blower的更多相关文章

  1. 【14.36%】【codeforces 614C】Peter and Snow Blower

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  2. 【CodeForces 613A】Peter and Snow Blower

    题 题意 给出原点(不是(0,0)那个原点)的坐标和一个多边形的顶点坐标,求多边形绕原点转一圈扫过的面积(每个顶点到原点距离保持不变). 分析 多边形到原点的最小距离和最大距离构成的两个圆之间的圆环就 ...

  3. 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 ...

  4. codeforce #339(div2)C Peter and Snow Blower

    Peter and Snow Blower 题意:有n(3 <= n <= 100 000)个点的一个多边形,这个多边形绕一个顶点转动,问扫过的面积为多少? 思路:开始就认为是一个凸包的问 ...

  5. A. Peter and Snow Blower 解析(思維、幾何)

    Codeforce 613 A. Peter and Snow Blower 解析(思維.幾何) 今天我們來看看CF613A 題目連結 題目 給你一個點\(P\)和\(n\)個點形成的多邊形(照順或逆 ...

  6. 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 ...

  7. CodeForces 614C Peter and Snow Blower

    简单计算几何,只要算出圆心到多边形上的最短距离和最长距离即可 #include<cstdio> #include<cstring> #include<cmath> ...

  8. codeforces 613A. Peter and Snow Blower

    题目链接 给一个多边形, 一个多边形外的定点, 求这个点距离多边形的最短距离和最长距离. 最长距离肯定是和某个顶点的连线, 而最短距离是和点的连线或是和某条边的连线. 对于一条边上的两个点a, b, ...

  9. Peter and Snow Blower CodeForces - 613A (点到线段距离)

    大意: 给定多边形, 给定点$P$, 求一个以$P$为圆心的最小的圆环包含整个多边形. #include <iostream> #include <cmath> #define ...

随机推荐

  1. FPGA软件使用基础之ISE下载配置 XILINX 下载器使用

    重新编辑 转载于https://www.cnblogs.com/lpp2jwz/p/7306020.html 下载程序 下载BIT 格式程序到FPGA 先插好下载器 在 ISE 中编译完 BIT 文件 ...

  2. SAP字段与表的对应关系

    SAP字段与表的对应关系   MASTER DATA-主数据 Customer Master KNA1                         Customer Basic Data KNB1 ...

  3. Linux的vi编辑器笔记

    vi编辑器,全称是visual interface,可以执行输出.删除.查找.替换等众多的文本操作. vi并不是一个排版程序,不可以对字体.格式.段落等其他的属性进行编排. vi是全屏文本编辑程序,没 ...

  4. java多线程同步机制

    一.关键字: thread(线程).thread-safe(线程安全).intercurrent(并发的) synchronized(同步的).asynchronized(异步的). volatile ...

  5. RN 上传文件到以及上传文件到七牛云(初步)

    本文将介绍: 如何使用原生 Javascript 上传文件 如何使用七牛云 SDK 上传文件到七牛云 在 App 中文件上传是一个非常重要的需求,但是翻遍 React Naitve 的官方文档没有发现 ...

  6. 关于js中splice方法返回的结果

    一.前言 刚刚在使用splice()方法,发现这个方法返回的是删除后的数组元素,如果要获取删除指定元素后的数组,直接调用原来的数组即可!因为splice()会改变原来数组!之前对splice()方法一 ...

  7. 关于python的基础知识

    一,编程语言的类型: 1.编译型 2.解释型 3.静态语言 4.动态语言 5.强类型定义语言 6.弱类型定义语言 编译型vs解释型 编译型: 优点:编译器一般会有预编译的过程对代码进行优化.因为编译只 ...

  8. Java生成指定长度的随机数

    char[] str = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', ' ...

  9. 详细解说Tomcat 设置虚拟路径的几种方法及为什么设置虚拟路径

    说明:此次使用的是Tomcat 7.0 很多朋友都会很疑惑,既然我们都知道在Tomcat服务器上部署项目只要将项目打包,然后放到webapps目录下就可以了,为什么还需要配置虚拟路径?的确,把项目放到 ...

  10. python中shutil模块

    shutil是对OS中文件操作的补充:移动.复制.打包.压缩.解压. 1.copy文件内容到另一个文件,可以copy指定大小的内容. shutil.copyfileobj(fsrc, fdst[, l ...