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. ASP.NET性能监视参数详解

    性能监视器- Performance Monitor 性能监视器是Windows自带的系统资源和性能监视工具. 性能监视器能够量化地提供CPU使用率, 内存分配状况, 异常派发情况, 线程调度频率等信 ...

  2. IOS实现UIButton图文混排、自定义按钮按下和正常状态下不同的背景颜色、根据文字长度自定义UIButton长度

    在一些项目中,我们需要自定义自己的UIButton,使Button上面同时具有图片和文字描述,实现自定义UIButton的图文混排. 首先我们需要定义一个继承自UIButton的类,同时实现自己的in ...

  3. POJ 1797 Heavy Transportation 最短路变形(dijkstra算法)

    题目:click here 题意: 有n个城市,m条道路,在每条道路上有一个承载量,现在要求从1到n城市最大承载量,而最大承载量就是从城市1到城市n所有通路上的最大承载量.分析: 其实这个求最大边可以 ...

  4. Android应用开发提高篇(5)-----Camera使用

    链接地址:http://www.cnblogs.com/lknlfy/archive/2012/03/06/2382679.html 一.概述 Camera是手机的一个很重要的设备,可以说现在的每一部 ...

  5. HDOJ 1308.Is It A Tree?

    2015-07-15 问题简述: 给出一组节点关系,判断由这些节点组成的图是否为一颗树. 树只有一个根节点,每个节点只有一条边指向它,没有环. 原题链接:http://poj.org/problem? ...

  6. 视频(其他)下载+tomcat 配置编码+图片上传限制大小

    视频下载:前台 jsp function downVideo(value,row,index){ return '<a href="<%=basePath%>admin/v ...

  7. MongoDB Query

    每条数据格式如下 { "_id" : ObjectId("5383298561aa33a422d8603e"), "day" : " ...

  8. sqlite详细介绍

    ------------------------------------------------------------------------------SQLite简介-------------- ...

  9. FreeBSD 10安装KDE桌面环境简介(亲测bsdconfig命令有效)

    FreeBSD 10出来一段时间了,自己摸索装上KDE环境,网上介绍的都是10以前版本的,要么对现在的不合适,走了一大圈弯路还是装不好:要么太繁琐且装了一堆无用的软件.本着让更多人能快速方面的入门Fr ...

  10. Struts2 中action之间的跳转(分享)

    例如从你的login.action到register.action  有两种实现方式 1. 设置type="redirect" <package  name="st ...