一直理解的最小覆盖圆就是外接圆。。原来还要分钝角和锐角。。。
钝角的话就为最长边的中点,对于这题分别枚举一下外接圆以及中点的圆,判一下是不是在园外。
#include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stdlib.h>
#include<vector>
#include<cmath>
#include<queue>
#include<set>
using namespace std;
#define N 100000
#define LL long long
#define INF 0xfffffff
const double eps = 1e-;
const double pi = acos(-1.0);
const double inf = ~0u>>;
struct Point
{
double x,y;
Point (double x=,double y =):x(x),y(y){}
}p[];
struct Circle
{
Point center;
double r;
};
typedef Point pointt;
pointt operator - (Point a,Point b)
{
return Point(a.x-b.x,a.y-b.y);
}
int dcmp(double x)
{
if(fabs(x)<eps) return ;
return x<?-:;
}
double dis(Point a)
{
return a.x*a.x+a.y*a.y;
}
double cross(Point a,Point b)
{
return a.x*b.y-a.y*b.x;
}
double area()
{
return fabs(cross(p[]-p[],p[]-p[]))/;
}
struct Circle Circumcircle()
{
Circle tmp;
double a,b,c,c1,c2;
double xa,ya,xb,yb,xc,yc;
a = sqrt(dis(p[]-p[]));
b = sqrt(dis(p[]-p[]));
c = sqrt(dis(p[]-p[]));
//¸ù¾Ýs = a*b*c/R/4£¬Çó°ë¾¶
tmp.r = (a*b*c)/(area()*4.0);
xa = p[].x;
ya = p[].y;
xb = p[].x;
yb = p[].y;
xc = p[].x;
yc = p[].y;
c1 = (dis(p[])-dis(p[]))/;
c2 = (dis(p[])-dis(p[]))/;
tmp.center.x = (c1*(ya-yc)-c2*(ya-yb))/((xa-xb)*(ya-yc)-(xa-xc)*(ya-yb));
tmp.center.y = (c1*(xa-xc)-c2*(xa-xb))/((ya-yb)*(xa-xc)-(ya-yc)*(xa-xb));
return tmp;
}
int main()
{
int t,i;
cin>>t;
int kk = ;
while(t--)
{
for(i = ;i <= ; i++)
scanf("%lf%lf",&p[i].x,&p[i].y);
Circle cc = Circumcircle();
Point pp;
scanf("%lf%lf",&pp.x,&pp.y);
double r = cc.r;
r*=r;
printf("Case #%d: ",++kk);
if(dis(pp-cc.center)>r)
{
puts("Safe");
continue;
}
r = dis(p[]-p[])/;
cc.center.x = (p[].x+p[].x)/;
cc.center.y = (p[].y+p[].y)/;
if(dcmp(dis(p[]-cc.center)-r)<=&&dcmp(dis(pp-cc.center)-r)>)
{
puts("Safe");
continue;
}
r = dis(p[]-p[])/;
cc.center.x = (p[].x+p[].x)/;
cc.center.y = (p[].y+p[].y)/;
if(dcmp(dis(p[]-cc.center)-r)<=&&dcmp(dis(pp-cc.center)-r)>)
{
puts("Safe");
continue;
}
r = dis(p[]-p[])/;
cc.center.x = (p[].x+p[].x)/;
cc.center.y = (p[].y+p[].y)/;
if(dcmp(dis(p[]-cc.center)-r)<=&&dcmp(dis(pp-cc.center)-r)>)
{
puts("Safe");
continue;
}
puts("Danger");
}
return ;
}