12779

#include <stdio.h>
#include <iostream>
#include <math.h>

using namespace std;

#define eps 1e-6
#define MX  1000000000
#define ll long long
struct POINT{int x,y;};

long long gcd(ll a,ll b)
{
	if(a%b==0)
	return b;
	else
	return gcd(b,a%b);
}

POINT pp[4];


bool find_perp_distance(POINT u,POINT v,POINT s,ll &B,ll &C,double &val)
{
	//form equation of st line uv (ax+by+c=0)
	double a,b,c,r;
	a = u.y-v.y;//y1-y2
	b = v.x-u.x;
	c = -(a*u.x+b*u.y);
	//distance from a point d = (a*x+b*y+c)/sqrt(a*a+b*b)
	r = fabs(a*s.x+b*s.y+c)/sqrt(a*a+b*b);

	//here if v can be considered as the edge of the square or diameter of the inscribed circle
	//so the area of the circle = d*d/4 * PI
	//cout<<r<<"\n";
	if(r<eps)
		return 0;
	if(r < val)
	{
		B=a*s.x+b*s.y+c;
		B=B*B;
		C=a*a+b*b;
		val=r;
	}
	return 1;
}
int main()
{
	int a,ans,b;
	double compare;
	ll B,C,g;
	bool f1,f2;
	while(cin>>a)
	{
		cin>>b;
		pp[0].x=a;
		pp[0].y=b;
		for(int i=1;i<=3;i++)
		{
			cin>>a>>b;
			pp[i].x=a;pp[i].y=b;
		}
		ans=0;
		for(int i=0;i<=3;i++)
		{
			ans+=(pp[i].x+pp[i].y);
		}

		if(ans==0)
		break;
		compare = MX;
		//find perpendicular distance from first point to the st line of 2nd and 3rd point
		f1 = find_perp_distance(pp[0],pp[1],pp[2],B,C,compare);
		f2 = find_perp_distance(pp[1],pp[2],pp[3],B,C,compare);

		if(f1*f2==0)
		{
			cout<<-1<<"\n";
			continue;
		}
		C*=4;
		g = gcd(B,C);
		B/=g;
		C/=g;
		cout<<"("<<B<<"/"<<C<<")*pi\n";
	}

	return 0;
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *