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. NOIP[2015] Day2题解

    问题 A: 跳石头 时间限制: 1 Sec  内存限制: 128 MB 题目描述 一年一度的"跳石头"比赛又要开始了! 这项比赛将在一条笔直的河道中进行,河道中分布着一些巨大岩石. ...

  2. jdk不同版本对String拼接的优化分析

    1. 测试demo代码 测试循环中字符串拼接优化 public class ForTest { public static void main(String[] args) { String a = ...

  3. 线上Java程序导致服务器CPU占用率过高的问题排除过程

    博文转至:http://www.jianshu.com/p/3667157d63bb,博文更好效果看原版,转本博文的目的就算是个书签吧,需要时候可以定位原文学习 1.故障现象 客服同事反馈平台系统运行 ...

  4. chrome开发工具指南(四)

    Sources 面板中 代码段是您可以从任何页面运行的小脚本(类似于小书签). 使用"Evaluate in Console"功能可以在控制台中运行部分代码段. 请注意,Sourc ...

  5. Linux shell中的竖线(|)——…

    原文地址:Linux shell中的竖线(|)--管道符号作者:潇潇 管道符号,是unix一个很强大的功能,符号为一条竖线:"|". 用法: command 1 | command ...

  6. sublime编辑器代码背景刺眼怎么修改?

    有些人觉得如上图大括号刺眼,怎么把它改得不那么刺眼呢? [第一步]打开Bracket Hightlighter插件的用户配置文件: 然后按ctrl+G跳转到第330行, 如图位置改为"sty ...

  7. sudoku--SE第二次作业

    git传送门 编译环境: windows10.vs2017 所用语言: c++ 首先作为一个晚上闭眼的玩家,我先来讲一下我的心路历程: 最开始接到作业的时候心里是拒绝的,刚出了一趟小远门就这样,就很难 ...

  8. 201521123073《Java程序设计》第4周学习总结

    一. 本周学习总结 二. 书面作业 1.注释的应用 2.面向对象设计(大作业1,非常重要) 2.1 将在网上商城购物或者在班级博客进行学习这一过程,描述成一个故事.(不得少于50字,参考QQ群中PPT ...

  9. 201521123018 《Java程序设计》第3周学习总结

    1. 本章学习总结 1. 学习了类的创建: 2. 学会利用快捷方式完成变量的getter和setter的设定: 3. 学会了静态变量和非静态变量的区别和定义: 4. 学习了构造函数的基本编写方法. 2 ...

  10. ArrayList和LinkedList区别及性能测试

    ArrayList和LinkedList是Java Lis接口的2个实现.它们的区别如下表所示: 底层结构 强项 弱项 ArrayList 数组 随机访问get和set 插入删除 LinkedList ...