计算几何 HDOJ 4720 Naive and Silly Muggles

时间:2023-03-09 09:04:55
计算几何 HDOJ 4720 Naive and Silly Muggles

题目传送门

/*
题意:给三个点求它们的外接圆,判断一个点是否在园内
计算几何:我用重心当圆心竟然AC了,数据真水:)
正解以后补充,http://www.cnblogs.com/kuangbin/archive/2013/09/11/3315055.html
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
using namespace std; int main(void) //HDOJ 4720 Naive and Silly Muggles
{
//freopen ("E.in", "r", stdin); double x1, y1, x2, y2, x3, y3, xq, yq;
double x0, y0;
double r;
double d;
int t, cas = ; scanf ("%d", &t);
while (t--)
{
scanf ("%lf%lf%lf%lf%lf%lf", &x1, &y1, &x2, &y2, &x3, &y3);
scanf ("%lf%lf", &xq, &yq);
x0 = (x1 + x2 + x3) / 3.0;
y0 = (y1 + y2 + y3) / 3.0;
r = (x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0);
d = (xq - x0) * (xq - x0) + (yq - y0) * (yq - y0); printf ("Case #%d: ", ++cas);
if (d <= r) puts ("Danger");
else puts ("Safe");
} return ;
} /*
Case #1: Danger
Case #2: Safe
Case #3: Safe
*/