HDU 4720 Naive and Silly Muggles (外切圆心)
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
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?
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.
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
Case #2: Safe
Case #3: Safe
外切圆心坐标
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 (外切圆心)的更多相关文章
- HDU 4720 Naive and Silly Muggles (简单计算几何)
Naive and Silly Muggles Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
- HDU 4720 Naive and Silly Muggles 2013年四川省赛题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4720 题目大意:给你四个点,用前三个点绘制一个最小的圆,而这三个点必须在圆上或者在圆内,判断最一个点如 ...
- HDU 4720 Naive and Silly Muggles 平面几何
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4720 解题报告:给出一个三角形的三个顶点坐标,要求用一个最小的圆将这个三个点都包含在内,另外输入一个点 ...
- 计算几何 HDOJ 4720 Naive and Silly Muggles
题目传送门 /* 题意:给三个点求它们的外接圆,判断一个点是否在园内 计算几何:我用重心当圆心竟然AC了,数据真水:) 正解以后补充,http://www.cnblogs.com/kuangbin/a ...
- Naive and Silly Muggles (计算几何)
Naive and Silly Muggles Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
- Naive and Silly Muggles
Problem Description Three wizards are doing a experiment. To avoid from bothering, a special magic i ...
- Naive and Silly Muggles hdu4720
Naive and Silly Muggles Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/ ...
- ACM学习历程—HDU4720 Naive and Silly Muggles(计算几何)
Description Three wizards are doing a experiment. To avoid from bothering, a special magic is set ar ...
- HDU-4720 Naive and Silly Muggles 圆的外心
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4720 先两两点之间枚举,如果不能找的最小的圆,那么求外心即可.. //STATUS:C++_AC_0M ...
随机推荐
- 关于js封装框架类库之选择器引擎(二)
在上篇介绍了选择器的获取标签.id.类名的方法,现在我们在上篇基础上继续升级 1.问题描述:上篇get('选择器')已经实现,如果get方法里是一个选择器的父元素,父元素是DOM对象,那么如何获取元素 ...
- objective-C学习笔记(九)ARC
ARC叫自动引用计数Automatic Reference Counting.针对堆上的对象,管理对象的创建和释放. 哪些对象受ARC管理: OC对象指针 Block指针 使用_attribute_( ...
- ajax联动
1.编写html代码,引入ajax文件 <script type="text/javascript" src="js/ajax.js"></s ...
- js 中日期 转换成时间戳 例如2013-08-30 转换为时间戳
//时间格式2014-02-02 14:10:00改成时间戳 //此时构造出来的时间是:2013/03/08 00:00:00. //这样得到的是一个数值,表示的是从1970年1月1日0点0分0秒到d ...
- Andy's First Dictionary
Description Andy, 8, has a dream - he wants to produce his very own dictionary. This is not an easy ...
- POJ 1151Atlantis 扫描线+线段树求矩形面积并
题目链接 #include <iostream> #include <vector> #include <cstdio> #include <cstring& ...
- A Byte of Python 笔记(11)异常:try..except、try..finally
第13章 异常 当你的程序中出现某些 异常的 状况的时候,异常就发生了. 错误 假如我们把 print 误拼为 Print,注意大写,这样 Python 会 引发 一个语法错误. 有一个SyntaxE ...
- 高质量程序设计指南C/C++语言——C++/C程序设计入门(2)
*标准C规定,编译器只取前31个字符作为有效的标识符,而标准C++则取前255个字符作为有效的标识符. *把具有特殊含义的字符输出到终端上,尤其是当它们出现在普通字符串或格式控制字符串中时,一般来说有 ...
- JAVA GUI学习 - JInternalFrame浮动窗口:可拖拽窗口(依赖于父窗口)
public class JInternalFrameKnow extends JInternalFrame { public JInternalFrameKnow() { this.setBound ...
- 通过自定义window来实现提示框效果
#import <UIKit/UIKit.h>#import <Foundation/Foundation.h> @interface ZMStatuBarHud : NSOb ...