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. hdu 2203亲和串 (kmp)

    #include<cstdio>#include<iostream>#include<cstring>#include<string>using nam ...

  2. 为什么C#动态调用Java的cxf多了bool型参数

    最近的一个项目需要C#调用Java的cxf发布的接口,接口参数文档只给我的是两个long型,但是通过我动态加载发现,参数是四个. 比如接口文档给的接口是 TestFunc(long, long); 而 ...

  3. 原生javascript实现老.虎机抽奖点名demo源码思路解析

    想着使用原生Javascript做一个随机点名的小应用, 也可以做抽奖使用. html简单化,人名单可以通过js生成并处理. 可以非常随意的添加修改人名字. 应用想带点特效,比如老.虎机转动的特效. ...

  4. 从零开始写驱动——vfd专用驱动芯片HT16514并行驱动程序编写

    前言 一直看别人搞的 vfd 很漂亮,前段时间淘了个 vfd 模块来,但没有模块资料,还好芯片没有打磨的,良心商家啊.周末抽空来研究一下这个东西. 从零开始 打开外壳 测试线路 查看芯片是 HT165 ...

  5. CV_EXPORTS定义及作用

    CV_EXPORTS 常用如下: class CV_EXPORTS MatExpr; template<typename _Tp> class CV_EXPORTS Size_; CV_E ...

  6. [NewCoder]复杂链表的复制

    看下面一个链表结点的定义: struct ComplexListNode { int val; struct ComplexListNode *next; struct ComplexListNode ...

  7. maxContainerCapability 设置不足

    异常: REDUCE capability required is more than the supported max container capability in the cluster. K ...

  8. javascript实现的功能--二级联动

    <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" ...

  9. php多图合并

    function mergerImg($imgs) { list($max_width, $max_height) = getimagesize($imgs['dst']); $dests = ima ...

  10. 转移服务器,DEDE网站遇到no input file specified!

    公司新配置了服务器,需要从旧服务器上把原来的站点迁移到新服务器,迁移.NET网站没有遇到任何问题,但是在迁移过来一个用DEDE做的网站后,访问首页出现No Input File Specified,后 ...