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 .

Examples

Input

Copy

3 0 0
0 1
-1 2
1 2

Output

Copy

12.566370614359172464

Input

Copy

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

Output

Copy

21.991148575128551812

Note

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

 

看了题解,要找凸多边形距离旋转中心的最远点和最近点,最近点不一定在点上,可能在边上。

去套白书的计算几何模板,最后才过。

还有大佬用三分找点到线段最小值,因为点到线段从一点到另一点的距离要么单调,要么先减后增。

还有大佬直接上数学了!根据线段所在直线方程得出垂线方程,解交点看在不在线段上,然后判断最近距离,太强了。

#include<bits/stdc++.h>
using namespace std;
#define eps 1e-10

int n;
double sx,sy;
double dismax,dismin=1e10;
const double pi=acos(-1);
struct Point{
	double x,y;
}a[100010];

typedef Point Vector;

int dcmp(double x)
{
	if(fabs(x)<eps)return 0;else return x<0?-1:1;
}

double Cross(Vector a,Vector b)
{
	return a.x*b.y-a.y*b.x;
}

Vector operator - (Vector a,Vector b){return (Vector){a.x-b.x,a.y-b.y};}

double Dot(Vector a,Vector b){return a.x*b.x+a.y*b.y;}

double Length(Vector a){return sqrt(Dot(a,a));}

double dist(Point p,Point a,Point b)
{ 
	Vector v1=b-a,v2=p-a,v3=p-b;
	if(dcmp(Dot(v1,v2))<0)return Length(v2);
	else if(dcmp(Dot(v1,v3))>0)return Length(v3);
	else return fabs(Cross(v1,v2)/Length(v1));
}

int main()
{
//	freopen("input.in","r",stdin);
	cin>>n>>sx>>sy;
	a[0].x=0;
	a[0].y=0;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].x>>a[i].y;
		a[i].x-=sx;
		a[i].y-=sy;
	}
	a[n+1]=a[1];
	for(int i=1;i<=n;i++)
	{
		dismax=max(dismax,a[i].x*a[i].x+a[i].y*a[i].y);
        dismin=min(dismin,dist(a[0],a[i],a[i+1]));
	}
	dismax=sqrt(dismax);
	printf("%.12f\n",pi*(dismax*dismax-dismin*dismin));
	exit(0);
}

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值