CodeForces 614C Peter and Snow Blower

CodeForces 614C  Peter and Snow Blower

time limit per test:2 seconds

memory limit per test:256 megabytes

input:standard input

output:standard output


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 (3~100000), 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 1e-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, if123456



Examples



Input
3 0 0
0 1
-1 2
1 2



Output
12.566370614359172464



Input
4 1 -1
0 0
1 2
2 0
1 1



Output
21.991148575128551812



Note

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

图片在这

开始写博客公式图片都是截图过来的。所以看题请看这:题目链接

思路:

  1. 最远的点一定是在大圆上,找到最远的点计算大圆半径;
  2. 输入的相邻两个点与p点围成的三角形为三角形PSE 的话,当角PSE或角PES为钝角时小圆半径是P到两点的最小值,其他情况小圆半径为P点到线段SE的距离,
代码:
#include
    
    
     
     
#include
     
     
      
      
#include
      
      
       
       
#define pi 4*atan(1)
using namespace std;

struct point
{
    long long x,y;
};

double dis(point a,point b)
{
    return sqrt(1.0*(a.x-b.x)*(a.x-b.x)+1.0*(a.y-b.y)*(a.y-b.y));
}

double dis2(point p,point s,point e)
{
    double a=dis(p,s);
    double b=dis(p,e);
    double c=dis(s,e);
    if(((1.0*(a*a+c*c-b*b))/(2.0*a*c))<=0||((1.0*(b*b+c*c-a*a))/(2.0*b*c))<=0)
       return min(a,b);
    double t=(1.0*(a+b+c))/2.0;
    double sh=sqrt(t*(t-a)*(t-b)*(t-c));
    return sh/c*2.0;
}
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        point o;
        scanf("%lld %lld",&o.x,&o.y);
        double maxd=-1;
        double mind=1e18;
        point p[100005];
        for(int i=0;i
       
       
        
        maxd)
                maxd=d;
            double d2=dis2(o,p[i],p[i+1]);
            if(d2
        
        
       
       
      
      
     
     
    
    

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值