HDU4720-Naive and Silly Muggles(求三角形外心)
来源:互联网 发布:我知我师我爱我师ppt 编辑:程序博客网 时间:2024/04/30 21:20
Naive and Silly Muggles
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1098 Accepted Submission(s): 732
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 of them are inside or on the border of the circle. And due to save the magic power, circle's area should as smaller as it could be.
Naive and silly "muggles"(who have no talents in magic) should absolutely not get into the circle, nor even on its border, or they will be in danger.
Given the position of a muggle, is he safe, or in serious danger?
Naive and silly "muggles"(who have no talents in magic) should absolutely not get into the circle, nor even on its border, or they will be in danger.
Given the position of a muggle, is he safe, or in serious danger?
Input
The first line has a number T (T <= 10) , indicating the number of test cases.
For each test case there are four lines. Three lines come each with two integers xi and yi (|xi, yi| <= 10), indicating the three wizards' positions. Then a single line with two numbers qx and qy (|qx, qy| <= 10), indicating the muggle's position.
For each test case there are four lines. Three lines come each with two integers xi and yi (|xi, yi| <= 10), indicating the three wizards' positions. Then a single line with two numbers qx and qy (|qx, qy| <= 10), indicating the muggle's position.
Output
For test case X, output "Case #X: " first, then output "Danger" or "Safe".
Sample Input
30 02 01 21 -0.50 02 01 21 -0.60 03 01 11 -1.5
Sample Output
Case #1: DangerCase #2: SafeCase #3: Safe
Source
2013 ACM/ICPC Asia Regional Online —— Warmup2
Recommend
zhuyuanchen520
题意: 给你三个点,找一个最小的圆能把三个点包住。点可以允许在圆内。再给你另一个点,如果该点在圆内或圆上输出Danger,在圆外输出Safe
解题思路:锐角或直角的话最小的圆就是外接圆,钝角的话圆的圆心就是在钝角的对边的中心
#include <iostream>#include <cstdio>#include <string>#include <cstring>#include <algorithm>#include <cmath>#include <queue>#include <vector>#include <set>#include <stack>#include <map>#include <climits>#include <functional>using namespace std;#define LL long longconst int INF=0x3f3f3f3f;const double exps=1e-8;struct point{ double x,y;};typedef struct point point;struct line{ point a,b;};typedef struct line line;point intersection(line u,line v){ point ret=u.a; double t=((u.a.x-v.a.x)*(v.a.y-v.b.y)-(u.a.y-v.a.y)*(v.a.x-v.b.x))/ ((u.a.x-u.b.x)*(v.a.y-v.b.y)-(u.a.y-u.b.y)*(v.a.x-v.b.x)); ret.x+=(u.b.x-u.a.x)*t; ret.y+=(u.b.y-u.a.y)*t; return ret;}double distan(point p1,point p2){ return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));}point cir(point a,point b,point c){ line u,v; u.a.x=(a.x+b.x)/2; u.a.y=(a.y+b.y)/2; u.b.x=u.a.x-a.y+b.y; u.b.y=u.a.y-a.x-b.x; v.a.x=(a.x+c.x)/2; v.a.y=(a.y+c.y)/2; v.b.x=v.a.x-a.y+c.y; v.b.y=v.a.y+a.x-c.x; return intersection(u,v);}int main(){ int t,cas=1; point a,b,c,d,e; scanf("%d",&t); while(t--) { scanf("%lf%lf",&a.x,&a.y); scanf("%lf%lf",&b.x,&b.y); scanf("%lf%lf",&c.x,&c.y); d=cir(a,b,c); scanf("%lf%lf",&e.x,&e.y); double ans1=distan(a,d); double ans2=distan(d,e); point k; if(distan(a,b)>distan(b,c)&&distan(a,b)>distan(a,c)) { k.x=(a.x+b.x)/2; k.y=(a.y+b.y)/2; if(ans1>distan(c,k)) { ans1=distan(c,k); ans2=distan(e,k); } } else if(distan(b,c)>distan(a,b)&&distan(b,c)>distan(a,c)) { k.x=(c.x+b.x)/2; k.y=(c.y+b.y)/2; if(ans1>distan(a,k)) { ans1=distan(a,k); ans2=distan(e,k); } } else { k.x=(c.x+a.x)/2; k.y=(c.y+a.y)/2; if(ans1>distan(b,k)) { ans1=distan(b,k); ans2=distan(e,k); } } if(ans1>=ans2) printf("Case #%d: Danger\n",cas++); else printf("Case #%d: Safe\n",cas++); } return 0;}
0 0
- HDU4720-Naive and Silly Muggles(求三角形外心)
- HDU 4720 Naive and Silly Muggles(计算几何, 求三角形外心)
- HDU4720----Naive and Silly Muggles
- HDU4720-Naive and Silly Muggles
- HDU4720 Naive and Silly Muggles
- hdu4720-(Naive and Silly Muggles)
- hdu 4720 Naive and Silly Muggles(三角形外接圆)
- Naive and Silly Muggles
- Naive and Silly Muggles
- HDOJ 4720 Naive and Silly Muggles 三角形外接圆
- HDU 4720 Naive and Silly Muggles(三角形最小覆盖圆)
- HDU 4720 Naive and Silly Muggles(计算几何)
- 四川省ACM竞赛(2013)---E - Naive and Silly Muggles
- Naive and Silly Muggles(判断钝角与三点共园)
- HDU 4720 Naive and Silly Muggles(圆心)
- hdu 4720 Naive and Silly Muggles
- HDU 4720 Naive and Silly Muggles
- hdu(4720) Naive and Silly Muggles
- AndroidStudio用户指南之快捷键
- platform之led驱动分析及测试程序
- python学习之路——爬虫基础
- 1002. 写出这个数 (20)
- Dijkstra-单源最短路径
- HDU4720-Naive and Silly Muggles(求三角形外心)
- HDU ACM Steps 1.2.1 hide handkerchief
- MTK lcm 背光流程
- 写在开始
- 在Ubuntu 16.04下安装Matlab 2017a
- 计算几何 求相交圆面积(余弦定理)
- EventBus进阶
- STL算法--函数对象
- 11059