Naive and Silly Muggles

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

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 x
i and y
i (|x
i, y
i| <= 10), indicating the three wizards' positions. Then a single line with two numbers q
x and q
y (|q
x, q
y| <= 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
 
Source
 

外切圆心坐标

x=(x1+x2+x3)/3;

y=(y1+y2+y3)/3;

import java.awt.Point;
import java.io.*;
import java.util.*; public class Main {
BufferedReader bu;
PrintWriter pw;
int t;
double x,y;
public static void main(String[] args) throws Exception {
new Main().work();
} void work() throws Exception {
Scanner sc=new Scanner(new InputStreamReader(System.in));
pw = new PrintWriter(new OutputStreamWriter(System.out), true);
t = sc.nextInt();
for (int p = 1; p <= t; p++) {
pw.print("Case #" + p + ": ");
double x1, y1;
double x2, y2;
double x3, y3;
double x4, y4;
//第一个wizard 的坐标
x1 = sc.nextDouble();
y1 = sc.nextDouble();
//第二个wizard 的坐标
x2 = sc.nextDouble();
y2 = sc.nextDouble();
//第三个wizard 的坐标
x3 = sc.nextDouble();
y3 = sc.nextDouble();
//muggles 坐标
x4 = sc.nextDouble();
y4 = sc.nextDouble();
//外切园的圆心坐标
x=(x1+x2+x3)/3;
y=(y1+y2+y3)/3;
//半径
double r=Math.sqrt((x1-x)*(x1-x)+(y1-y)*(y1-y));
//muggles到圆心的距离
double d=Math.sqrt((x4-x)*(x4-x)+(y4-y)*(y4-y)); if(d>r){
pw.println("Safe");
}
else{
pw.println("Danger");
}
}
}
}

HDU 4720 Naive and Silly Muggles (外切圆心)的更多相关文章

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

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

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

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

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

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

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

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

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

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

  6. Naive and Silly Muggles

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

  7. Naive and Silly Muggles hdu4720

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

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

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

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

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

随机推荐

  1. zoj 3708 Density of Power Network

    /*看英文和图我头都大了,不过很简单的.*/ #include<string.h> #include<stdio.h> ][],q[],w[]; int main(int ar ...

  2. Windows+Apache+PHP5配置

    今天配置Windows+Apache+PHP时,遇到的问题,记录下供大家参考,也供自己以后参考!需要特别注意的:PHP v9版本的 非线程安全的 只适用于IIS,5.3版本的NTS版的没有php5ap ...

  3. IOS 表视图(UITableVIew)的使用方法(5)表视图的编辑功能(删除)

    默认的,如果表视图支持编辑,那用户可以通过两种方式来删除某些行,其一为单击左侧的红色按钮后行右侧显示“Delete”按钮,其二为在单元行上的手指向左滑动,“Delete”按钮也会出现供用户单击.无论哪 ...

  4. JAVA中List、Map、Set的区别与选用

    类层次关系如下: Collection ├List│├LinkedList│├ArrayList│└Vector│ └Stack└SetMap├Hashtable├HashMap └WeakHashM ...

  5. File类常用方法

    File类是IO中常用的类 先介绍几个常用的方法: public boolean canRead(),public boolean canWrite() 测试当前文件是否可读可写,若是则返回true ...

  6. js 获取前天、昨天、今天、明天、后天的时间

    js 获取前天.昨天.今天.明天.后天的时间 2011-05-19 21:03   <html><head><meta http-equiv="Content- ...

  7. Android测试TestSuite的执行方法

    public class StartTest extends InstrumentationTestRunner {         public  TestSuite getAllTests() { ...

  8. 利用jxl读取excel合并的单元格的一个小样例

    工作中我们可能要把Excel文件的记录保存到数据库, 今天我用jxl读取Excel文件时遇到了合并格的问题,记录例如以下: 如Excel文件例如以下: watermark/2/text/aHR0cDo ...

  9. OutLook 2010 收件箱子文件夹收到新邮件时没有桌面通知

    开始---规则----管理规则和通知 规则和通知---电子邮件规则---批量选择账号---更改规则---在新邮件通知和窗口显示(选中)---确定 录入通知邮件消息---确定 效果如下:

  10. .Net将多个DLL打包为一个DLL(ILMerge)

    在做.Net底层编码过程中,为了功能独立,有可能会生成多个DLL,引用时非常不便.这方面微软提供了一个ILMerge工具原版DOS工具,可以将多个DLL合并成一个.下载完成后需要安装一下,然后通过DO ...