HDU 4720 Naive and Silly Muggles 平面几何
题目链接: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 平面几何的更多相关文章
- HDU 4720 Naive and Silly Muggles (外切圆心)
Naive and Silly Muggles Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- HDU 4720 Naive and Silly Muggles (简单计算几何)
Naive and Silly Muggles Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
- HDU 4720 Naive and Silly Muggles 2013年四川省赛题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4720 题目大意:给你四个点,用前三个点绘制一个最小的圆,而这三个点必须在圆上或者在圆内,判断最一个点如 ...
- 计算几何 HDOJ 4720 Naive and Silly Muggles
题目传送门 /* 题意:给三个点求它们的外接圆,判断一个点是否在园内 计算几何:我用重心当圆心竟然AC了,数据真水:) 正解以后补充,http://www.cnblogs.com/kuangbin/a ...
- Naive and Silly Muggles
Problem Description Three wizards are doing a experiment. To avoid from bothering, a special magic i ...
- Naive and Silly Muggles (计算几何)
Naive and Silly Muggles Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
- Naive and Silly Muggles hdu4720
Naive and Silly Muggles Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
- ACM学习历程—HDU4720 Naive and Silly Muggles(计算几何)
Description Three wizards are doing a experiment. To avoid from bothering, a special magic is set ar ...
- HDU-4720 Naive and Silly Muggles 圆的外心
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4720 先两两点之间枚举,如果不能找的最小的圆,那么求外心即可.. //STATUS:C++_AC_0M ...
随机推荐
- python安装报错:Microsoft Visual C++ 14.0 is required
保存详情如下: error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build T ...
- [转帖]TLS 版本问题
转帖 From https://www.cnblogs.com/xjnotxj/p/7252043.html 一.环境: CentOS 6.8nginx 1.6.0php 7.0.10 二.背景 最近 ...
- js 小程序获取本周七天
data: { weekdays:['','','','','','',''] }, onLoad: function (options) { let that = this; let now ...
- facenet模型训练
做下记录,脚本如下: 对比 python3 src/compare.py ../models/-/ ../faces/pyimgs/dashenlin/ytwRkvSdG1000058.png ../ ...
- Java的StringBuIlder扩容机制
JDK 1.6中,扩容的源码是这样: void expandCapacity(int minimumCapacity) { int newCapacity = (value.length + 1) * ...
- 第219天:Angular---过滤器
在Angular中,过滤器的功能主要是格式化数据表达式,且可以自定义过滤器.作用域(scope)主要服务于页面模板,在控制器和页面中起桥梁作用,保存模板中的数据对象,为模板中的元素提供方法和属性. 一 ...
- java 每一个对象都是根据hashCode区别的 每次返回不同的内存地址
可以通过hashCode比较对象,hashCode如果重写的话 返回的内存地址是一样的 则不能创建对象
- TypeError: to_categorical() got an unexpected keyword argument 'nb_classes'
在学习莫烦教程中keras教程时,报错:TypeError: to_categorical() got an unexpected keyword argument 'nb_classes',代码如下 ...
- Codeforces Round#509 Div.2翻车记
A:签到 #include<iostream> #include<cstdio> #include<cmath> #include<cstdlib> # ...
- 触发Full GC执行的情况 以及其它补充信息
除直接调用System.gc外,触发Full GC执行的情况有如下四种.1. 旧生代空间不足旧生代空间只有在新生代对象转入及创建为大对象.大数组时才会出现不足的现象,当执行Full GC后空间仍然不足 ...