Naive and Silly Muggles

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 452    Accepted Submission(s): 307

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?
 
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.
 
Output
For test case X, output "Case #X: " first, then output "Danger" or "Safe".
 
Sample Input
3
0 0
2 0
1 2
1 -0.5

0 0
2 0
1 2
1 -0.6

0 0
3 0
1 1
1 -1.5

 
Sample Output
Case #1: Danger
Case #2: Safe
Case #3: Safe
 #include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
double p[][],x,y;
void fun()
{
double a=*(p[][]-p[][]);
double a1=*(p[][]-p[][]);
double b=*(p[][]-p[][]);
double b1=*(p[][]-p[][]);
double c=p[][]*p[][]+p[][]*p[][]-p[][]*p[][]-p[][]*p[][];
double c1=p[][]*p[][]+p[][]*p[][]-p[][]*p[][]-p[][]*p[][];
x=(a1*c-a*c1)/(b*a1-b1*a);
y=(c*b1-c1*b)/(b1*a-b*a1);
}
double dis(int k)
{
double sum;
sum=sqrt((x-p[k][])*(x-p[k][])+(y-p[k][])*(y-p[k][]));
return sum;
}
int main()
{
int t,i,j,n;
scanf("%d",&t);
for(i=; i<=t; i++)
{
for(j=; j<; j++)scanf("%lf%lf",&p[j][],&p[j][]);
printf("Case #%d: ",i);
double a=((p[][]-p[][])*(p[][]-p[][])+(p[][]-p[][])*(p[][]-p[][]));
double b=((p[][]-p[][])*(p[][]-p[][])+(p[][]-p[][])*(p[][]-p[][]));
double c=((p[][]-p[][])*(p[][]-p[][])+(p[][]-p[][])*(p[][]-p[][]));
if(a*a+b*b<c*c)
{
x=(p[][]+p[][])/;
y=(p[][]+p[][])/;
}
else if(a*a+c*c<b*b)
{
x=(p[][]+p[][])/;
y=(p[][]+p[][])/;
}
else if(b*b+c*c<a*a)
{
x=(p[][]+p[][])/;
y=(p[][]+p[][])/;
}
else
{
fun();
}
double di=dis();
double di1=dis();
if(di<di1)
{
cout<<"Safe"<<endl;
}
else cout<<"Danger"<<endl;
}
}

Naive and Silly Muggles hdu4720的更多相关文章

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

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

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

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

  3. Naive and Silly Muggles

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

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

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

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

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

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

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

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

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

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

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

  9. HDU 4720 Naive and Silly Muggles 平面几何

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4720 解题报告:给出一个三角形的三个顶点坐标,要求用一个最小的圆将这个三个点都包含在内,另外输入一个点 ...

随机推荐

  1. Java内存模型_基础

    线程之间的通信机制有两种: 1.共享内存:线程之间共享程序的公共状态,通过写-读内存中的公共状态进行隐式的通信. 2.消息传递:线程之间没有公共状态,线程之间必须发送消息来显示的进行通信 同步:是指程 ...

  2. Thread类源码剖析

    目录 1.引子 2.JVM线程状态 3.Thread常用方法 4.拓展点 一.引子 说来也有些汗颜,搞了几年java,忽然发现竟然没拜读过java.lang.Thread类源码,这次特地拿出来晒一晒. ...

  3. PHP常量定义define与const

    一.const PHP5.3以前,const只能在类内部声明变量,5.3+允许在外部声明变量,但还不能使用常量计算! const ONE = 1; const WORD = 'hello world' ...

  4. 删除git项目

    主页,点击右上头像-->your profile-->Popular repositories ,看到你要删除的项目,点击进去 --> 上面 选择settings-->到页面最 ...

  5. 详解 anjularjs的ui-route(多视图、视图嵌套、视图传参)

    最近整理了一下anjularjs的第三方插件ui-route,在这就以一个demo的形式讲解一下.整片博客均以开头的demo代码为例.下边是个目录,大家可以酌情直接跳转浏览. 1. demo的代码 2 ...

  6. GUI(GroupLayout 分组布局)

    组:一些组件的集合                       连续组:一个接着一个摆放                       并行组:一个组在另一个组的顶部                   ...

  7. JAVA基础第九组(5道题)

    41.[程序41] 题目:海滩上有一堆桃子,五只猴子来分.第一只猴子把这堆桃子凭据分为五份,多了一个,这只猴子把多的一       个扔入海中,拿走了一份.第二只猴子把剩下的桃子又平均分成五份,又多了 ...

  8. 团队作业——Alpha冲刺之事后诸葛亮

    小组成员: 武健男:201421123091 林俊鹏:201421123076 何跃斌:201421123082 陈鑫龙:201421123078 潘益靖:201421123086 黄睿:201421 ...

  9. Swing-文本输入组件(一)

    Swing控件中,能够实现用户输入的有JTextField.JPasswordField.JTextArea和JTextPane.下面分别进行介绍. JTextField 最简单的文本控件,常见的登陆 ...

  10. 201521123089 《Java程序设计》第8周学习总结

    1. 本周学习总结 1.1 以你喜欢的方式(思维导图或其他)归纳总结集合与泛型相关内容. 1.2 选做:收集你认为有用的代码片段 2. 书面作业 本次作业题集集合 1.List中指定元素的删除(题目4 ...