计算几何 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 = 0;

    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 0;
}

/*
Case #1: Danger
Case #2: Safe
Case #3: Safe
*/
时间: 2024-12-09 19:22:35

计算几何 HDOJ 4720 Naive and Silly Muggles的相关文章

HDOJ 4720 Naive and Silly Muggles 三角形外接圆

当是钝角三角形时,就是最长边为直径的圆最小. 否则,求三角形的外接圆 Naive and Silly Muggles Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 700    Accepted Submission(s): 451 Problem Description Three wizards are doing a exper

HDU 4720 :Naive and Silly Muggles

题目:HDU 4720 :Naive and Silly Muggles 题目大意:这题的意思是给出三个点, 然后在给出另一个点,问这个点会不会在覆盖前面三个点的最小的圆里面(包括边界), 在里面最输出danger, 如果任何情况下这个点都不在圆里面,那么就输出safe. 解题思路:三个点最小的覆盖的圆是三角形的外接圆,这样的圆面积一定是最小的. 但是相同面积的圆,所在的位置,覆盖的点会是不一样的.例如垂心关于三条边的对称点,以某个对称点为圆心的圆用之前的半径做圆,如果能够覆盖原来的三个点(点可

hdu 4720 Naive and Silly Muggles(几何)

题目链接:hdu 4720 Naive and Silly Muggles 题目大意:给出三点,找出一个圆,要求面积尽量小,并且三点必须在园内,如果可以找到一个圆,使得说第4个点不在圆内则是安全的. 解题思路:面积最小即三个点外切圆,根据三角形两条边的垂直平分线求出圆心.判断第4个点是否在圆内只要计算距离即可. 然后还要考虑说面积和外切圆相同,但是圆心不同的圆. #include <cstdio> #include <cstring> #include <cmath>

Naive and Silly Muggles(计算几何 判断点是否在三点形成的最小圆内)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4720 Problem Description Three wizards are doing a experiment. To avoid from bothering, a special magic is set around them. The magic forms a circle, which covers those three wizards, in other words, all

ACM学习历程—HDU4720 Naive and Silly Muggles(计算几何)

Description Three wizards are doing a experiment. To avoid from bothering, a special magic is set around them. The magic forms a circle, which covers those three wizards, in other words, all of them are inside or on the border of the circle. And due

hdu4720Naive and Silly Muggles

链接 一直理解的最小覆盖圆就是外接圆..原来还要分钝角和锐角... 钝角的话就为最长边的中点,对于这题分别枚举一下外接圆以及中点的圆,判一下是不是在园外. 1 #include <iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<stdlib.h> 6 #include<vector> 7 #include<cmat

2013 成都邀请赛

今年又要打邀请赛了,前段时间做比赛都被虐的够呛.感觉不会再爱了...所以挂了下去年的成都邀请赛的题目.发现简单题还是能切上几道的,可是难题就无能为力了.. .阿门,还是水平差得远啊.. . (ps:近期感觉状态不佳.依靠了队友神勇的发挥. .. Current Time: 2014-05-15 08:43:24 Contest Type: Public Start Time: 2014-05-14 15:10:00 Contest Status: Ended End Time: 2014-05-

hdoj 1086 You can Solve a Geometry Problem too 【计算几何】

题意:就是判断各线段之间有没有交点. 判断两线段相交,要运用到叉积.两个线段相交肯定相互跨越,假设一个条线段(p1p2),另一条是(q1q2),那么p1p2肯定在q1q2线段的两侧,那么运用叉积如果p1p2跨越q1q2的话(q1p1)x(q2p2)<= 0.同样也要验证 q1q2是不是也跨越p1p2,注意:p1p2跨越q1q2,不代两个线段相交,可能是p1p2跨越直线q1q2,所以说还是要再次判断q1q2是不是跨越p1p2 还有另外一种比较容易理解的解法: 就是如果两个线段相交,那么两线段两端端

hdoj 2036 (计算几何,叉积求面积)

改革春风吹满地 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 24179    Accepted Submission(s): 12504 Problem Description “ 改革春风吹满地,不会AC没关系;实在不行回老家,还有一亩三分地.谢谢!(乐队奏乐)” 话说部分学生心态极好,每天就知道游戏,这次考试如此简单的题目,也是云