题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4720

解题报告:给出一个三角形的三个顶点坐标,要求用一个最小的圆将这个三个点都包含在内,另外输入一个点,问这个点是否在这个圆的圆外,如果在圆外,输出Safe,否则输出Danger。

现在的主要目的其实就是求这个最小的三角形的圆心坐标,很显然,当这个三角形是锐角三角形的时候,这个最小的圆就是这个锐角三角型的外接圆,否则就是以这个三角形最长的那条边的中点为圆心,以这条边的一半为半径的圆。

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<cmath>
using namespace std; int judge(double x1,double y1,double x2,double y2,double x3,double y3)
{
double X1 = x2 - x1;
double Y1 = y2 - y1;
double X2 = x3 - x1;
double Y2 = y3 - y1;
return (X1*X2 + Y1*Y2 > );
} double dis(double x1,double y1,double x2,double y2)
{
return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
} int main()
{
int T,Case = ;
double x1,y1,x2,y2,x3,y3,x4,y4,a,b,c;
scanf("%d",&T);
while(T--)
{
scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
printf("Case #%d: ",Case++);
if(judge(x1,y1,x2,y2,x3,y3) && judge(x2,y2,x1,y1,x3,y3) && judge(x3,y3,x1,y1,x2,y2))
{
double x0 = (x1 + x2 + x3) / 3.0;
double y0 = (y1 + y2 + y3) / 3.0;
if(dis(x0,y0,x4,y4) > dis(x0,y0,x1,y1))
printf("Safe\n");
else printf("Danger\n");
}
else
{
a = dis(x1,y1,x2,y2);
b = dis(x1,y1,x3,y3);
c = dis(x2,y2,x3,y3);
if(a >= b && a >= c)
{
double x0 = (x1 + x2) / 2.0;
double y0 = (y1 + y2) / 2.0;
if(dis(x0,y0,x4,y4) > a / 2.0)
printf("Safe\n");
else printf("Danger\n");
}
else if(b >= a && b >= c)
{
double x0 = (x1 + x3) / 2.0;
double y0 = (y1 + y3) / 2.0;
if(dis(x0,y0,x4,y4) > b / 2.0)
printf("Safe\n");
else printf("Danger\n");
}
else if(c >= a && c >= b)
{
double x0 = (x2 + x3) / 2.0;
double y0 = (y2 + y3) / 2.0;
if(dis(x0,y0,x4,y4) > c / 2.0)
printf("Safe\n");
else printf("Danger\n");
}
}
}
return ;
}

HDU 4720 Naive and Silly Muggles 平面几何的更多相关文章

  1. HDU 4720 Naive and Silly Muggles (外切圆心)

    Naive and Silly Muggles Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...

  2. HDU 4720 Naive and Silly Muggles (简单计算几何)

    Naive and Silly Muggles Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/ ...

  3. HDU 4720 Naive and Silly Muggles 2013年四川省赛题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4720 题目大意:给你四个点,用前三个点绘制一个最小的圆,而这三个点必须在圆上或者在圆内,判断最一个点如 ...

  4. 计算几何 HDOJ 4720 Naive and Silly Muggles

    题目传送门 /* 题意:给三个点求它们的外接圆,判断一个点是否在园内 计算几何:我用重心当圆心竟然AC了,数据真水:) 正解以后补充,http://www.cnblogs.com/kuangbin/a ...

  5. Naive and Silly Muggles

    Problem Description Three wizards are doing a experiment. To avoid from bothering, a special magic i ...

  6. Naive and Silly Muggles (计算几何)

    Naive and Silly Muggles Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/ ...

  7. Naive and Silly Muggles hdu4720

    Naive and Silly Muggles Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/ ...

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

    Description Three wizards are doing a experiment. To avoid from bothering, a special magic is set ar ...

  9. HDU-4720 Naive and Silly Muggles 圆的外心

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4720 先两两点之间枚举,如果不能找的最小的圆,那么求外心即可.. //STATUS:C++_AC_0M ...

随机推荐

  1. foo()与@foo()的区别

    1.@foo() 是错误控制输出,foo()是正常调用输出. 2.@符号在PHP 中可以忽略错误报告,对于表达式有提示错误的,但有不影响语句执行的,可以在表达式之前加@. 3.可以把@符号放在变量.函 ...

  2. springmvc上传文件报错org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [org.springframework.web.multipart.MultipartFile]

    在用springmvc+mybatis进行项目开发时,上传文件抛异常... org.springframework.beans.BeanInstantiationException: Could no ...

  3. Node初识笔记 1第一周

    #下载安装好node > https://nodejs.org/en/ #  打开cmd  调整好执行路径 . 1.js是JS文件名,cd调招路径,‘node’+空格 +JS文件名(带上扩展名) ...

  4. MachineLearning Exercise 4 :Neural Networks Learning

    nnCostFunction 消耗公式: a1 = [ones(m,) X]; z2 = a1*Theta1'; pre = sigmoid(a1*Theta1'); a2 = [ones(m,) p ...

  5. spring通过工厂模式解决页面耦合问题

    spring通过工厂模式解决页面耦合问题

  6. Power Strings POJ - 2406(next水的一发 || 后缀数组)

    后缀数组专题的 emm.. 就next 循环节../ 有后缀数组也可以做 从小到大枚举长度i,如果长度i的子串刚好是重复了len/i次,应该满足len % i == 0和rank[0] - rank[ ...

  7. oracle 存储过程创建报错 Procedure created with compilation errors

    出现这错误的话,存储过程还是会成功创建的,创建好后再逐个打开查找存储过程的问题 问题:基本上就是存储过程里面的表不存在,dblink 不存在    ,用户名.xx表  要么用户名不存在要么表不存在 创 ...

  8. JeeSite 4.x SAAS 多租户技术设计方案

    SaaS 是 Software-as-a-Service(软件即服务)的简称,从技术角度上可称之为 “多租户技术或称多重租赁技术”.它与 “按需软件.应用服务提供商.托管软件” 所具有相似的含义.它是 ...

  9. BZOJ 2732: [HNOI2012]射箭

    2732: [HNOI2012]射箭 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 2532  Solved: 849[Submit][Status] ...

  10. Longest Word in Dictionary through Deleting - LeetCode

    目录 题目链接 注意点 解法 小结 题目链接 Longest Word in Dictionary through Deleting - LeetCode 注意点 长度一样的字符串要按字典序返回较小的 ...