hdu4720Naive and Silly Muggles
一直理解的最小覆盖圆就是外接圆。。原来还要分钝角和锐角。。。
钝角的话就为最长边的中点,对于这题分别枚举一下外接圆以及中点的圆,判一下是不是在园外。
- #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 ;
- }
hdu4720Naive and Silly Muggles的更多相关文章
- 计算几何 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/ ...
- 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 4720Naive and Silly Muggles热身赛2 1005题(分锐角钝角三角形讨论)
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/ ...
- HDU 4720 Naive and Silly Muggles (简单计算几何)
Naive and Silly Muggles Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
- HDUOJ-------Naive and Silly Muggles
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 ...
随机推荐
- js中字符串转换为数字的方法
parseInt; parseFload; +; parseInt() 和 parseFloat() 函数会尝试逐个解析字符串中的字符,直到遇上一个无法被解析成数字的字符,然后返回该字符前所有数字字符 ...
- StringUtils中 isEmpty 和isBlank的区别
StringUtils方法的操作对象是java.lang.String类型的对象,是JDK提供的String类型操作方法的补充,并且是null安全的(即如果输入参数String为null则不会抛出Nu ...
- meta标签部分总结
<meta>标签用于提供页面的元信息,比如针对搜索引擎和更新频度的描述和关键词.由于看到很多网页<head>里面<meta>标签的内容很多,对这些标签含义了解不太清 ...
- YTU 3019: 螺旋方阵
3019: 螺旋方阵 时间限制: 1 Sec 内存限制: 128 MB 提交: 2 解决: 2 题目描述 以下是一个5*5阶螺旋方阵.设计一个程序,输出该形式的n*n阶方阵(顺时针方向旋进). ...
- MySQL 及 SQL 注入
如果您通过网页获取用户输入的数据并将其插入一个MySQL数据库,那么就有可能发生SQL注入安全的问题. 本章节将为大家介绍如何防止SQL注入,并通过脚本来过滤SQL中注入的字符. 所谓SQL注入,就是 ...
- 周赛-Expression 分类: 比赛 2015-08-02 09:35 3人阅读 评论(0) 收藏
A. Expression time limit per test1 second memory limit per test256 megabytes inputstandard input out ...
- IP Address 分类: POJ 2015-06-12 19:34 12人阅读 评论(0) 收藏
IP Address Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 19125 Accepted: 11053 Desc ...
- 基本的MFC多线程
多线程程序我本来是能够来写的.但是由于在图像处理的过程中,对于这方面知识使用的比较少,造成重复忘记的情况.这里再次进行整理学习,特别注重和“图像处理”理清关系,为下一步使用奠定基础. 这里实现的是工作 ...
- python中string.casefold和string.lower区别
string.casefold和string.lower 区别 python 3.3 引入了string.casefold 方法,其效果和 string.lower 非常类似,都可以把字符串变成小写, ...
- interrupt ,interrupted 和 isInterrupted
1.interrupt interrupt方法用于中断线程.调用该方法的线程的状态为将被置为"中断"状态. 注意:线程中断仅仅是置线程的中断状态位,不会停止线程.需要用户自己去监 ...