博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HDU 4720 Naive and Silly Muggles (外切圆心)
阅读量:6579 次
发布时间:2019-06-24

本文共 2343 字,大约阅读时间需要 7 分钟。

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");			}		}	}}

 

 

 

 

转载地址:http://jbino.baihongyu.com/

你可能感兴趣的文章
2018年7月1日笔记
查看>>
尝试使用iReport4.7(基于Ubuntu Desktop 12.04 LTS)
查看>>
动态规划:金矿模型
查看>>
子元素应该margin-top为何会影响父元素【转】
查看>>
AJAX 状态值(readyState)与状态码(status)详解
查看>>
BZOJ3668:[NOI2014]起床困难综合症(贪心)
查看>>
LightOJ 1245(Harmonic Number (II))
查看>>
小知识记录
查看>>
css3 animate 和关键帧 @-webkit-keyframes
查看>>
文字链接颜色设置
查看>>
图片转流
查看>>
ubunto应用软件
查看>>
HTML 标签说明
查看>>
锋利的jQuery-2--判断jQuery获取到的对象是否存在$().length
查看>>
linux 查询系统版本命令、查询端口号是否被占用命令
查看>>
java笔记八:IO流之字符流与字符缓冲流
查看>>
Docker 命令收集
查看>>
myeclipse注册码生成器
查看>>
怎样快速学好PHP技术之PHP学习方法总结
查看>>
iOS App间相互跳转漫谈 part2
查看>>