Naive and Silly Muggles hdu4720
Naive and Silly Muggles
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 452 Accepted Submission(s): 307
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 xi and yi (|xi, yi| <= 10), indicating the three wizards' positions. Then a single line with two numbers qx and qy (|qx, qy| <= 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
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <algorithm>
using namespace std;
double p[][],x,y;
void fun()
{
double a=*(p[][]-p[][]);
double a1=*(p[][]-p[][]);
double b=*(p[][]-p[][]);
double b1=*(p[][]-p[][]);
double c=p[][]*p[][]+p[][]*p[][]-p[][]*p[][]-p[][]*p[][];
double c1=p[][]*p[][]+p[][]*p[][]-p[][]*p[][]-p[][]*p[][];
x=(a1*c-a*c1)/(b*a1-b1*a);
y=(c*b1-c1*b)/(b1*a-b*a1);
}
double dis(int k)
{
double sum;
sum=sqrt((x-p[k][])*(x-p[k][])+(y-p[k][])*(y-p[k][]));
return sum;
}
int main()
{
int t,i,j,n;
scanf("%d",&t);
for(i=; i<=t; i++)
{
for(j=; j<; j++)scanf("%lf%lf",&p[j][],&p[j][]);
printf("Case #%d: ",i);
double a=((p[][]-p[][])*(p[][]-p[][])+(p[][]-p[][])*(p[][]-p[][]));
double b=((p[][]-p[][])*(p[][]-p[][])+(p[][]-p[][])*(p[][]-p[][]));
double c=((p[][]-p[][])*(p[][]-p[][])+(p[][]-p[][])*(p[][]-p[][]));
if(a*a+b*b<c*c)
{
x=(p[][]+p[][])/;
y=(p[][]+p[][])/;
}
else if(a*a+c*c<b*b)
{
x=(p[][]+p[][])/;
y=(p[][]+p[][])/;
}
else if(b*b+c*c<a*a)
{
x=(p[][]+p[][])/;
y=(p[][]+p[][])/;
}
else
{
fun();
}
double di=dis();
double di1=dis();
if(di<di1)
{
cout<<"Safe"<<endl;
}
else cout<<"Danger"<<endl;
}
}
Naive and Silly Muggles hdu4720的更多相关文章
- ACM学习历程—HDU4720 Naive and Silly Muggles(计算几何)
Description Three wizards are doing a experiment. To avoid from bothering, a special magic is set ar ...
- 计算几何 HDOJ 4720 Naive and Silly Muggles
题目传送门 /* 题意:给三个点求它们的外接圆,判断一个点是否在园内 计算几何:我用重心当圆心竟然AC了,数据真水:) 正解以后补充,http://www.cnblogs.com/kuangbin/a ...
- Naive and Silly Muggles
Problem Description Three wizards are doing a experiment. To avoid from bothering, a special magic i ...
- 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 (外切圆心)
Naive and Silly Muggles Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Oth ...
- 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 圆的外心
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4720 先两两点之间枚举,如果不能找的最小的圆,那么求外心即可.. //STATUS:C++_AC_0M ...
- 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 解题报告:给出一个三角形的三个顶点坐标,要求用一个最小的圆将这个三个点都包含在内,另外输入一个点 ...
随机推荐
- windows下命令行模式中cd命令无效的原因
当我们执行cmd 想切换当前工作目录时,会发现windows下命令行模式中cd命令没有生效,到底是什么原因呢? 例如: 当我们想切换到 D:\MySql\mysql-5.7.19-winx64\bin ...
- 模仿Spring实现注解注入
写这个极其蛋疼,我一直在想我们用SSM写项目时,写Service和Controller的时候,会给Service和Controller私有属性,比如Service需要dao,Controller需要S ...
- css基础:格式与布局
1.定位:position:fixed:锁定位置,相当于屏幕位置锁定,不随页面移动. position:absolute:绝对位置,相对于页面定位,随页面移动. position:relative:相 ...
- 移动webapp的那些bug
bug持续更新中... 测试浏览器 Chrome: 61.0.3163.73 Safari: 10.0(IOS 10.3.3) Github: webapp-bugs 1. IOS overflow: ...
- Angular 新手容易碰到的坑
Q1.<div ng-include="views/user/show.html"></div> 错在哪里? 如果你这么写过,会发现这个位置啥也没有加载出来 ...
- jsp、freemarker、velocity区别详解
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt172 在java领域,表现层技术主要有三种:jsp.freemarker.v ...
- tomcat 和 jboss access log 日志输出详解
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt179 工作中nginx+jboss/tomcat反向代理集成,想打开后端jb ...
- [转]Java7中的ForkJoin并发框架初探(中)——JDK中实现简要分析
详见: http://blog.yemou.net/article/query/info/tytfjhfascvhzxcytp85 根据前文描述的Doug Lea的理论基础,在JDK1.7中已经给 ...
- sql 比较不同行不同字段值
需求:在一个表table中有两三列,分别是"货物名称"."进货时间"."出货时间"."存放天数",货物名称和两种&quo ...
- 团队作业8----第二次项目冲刺(Beta阶段) 第一天
BETA阶段冲刺第一天 1.开了个小会议 2.每个人的工作 (1) 昨天已完成的工作: 今天是第一天,所以是新的开始. (2) 今天计划完成的工作: (3) 工作中遇到的困难: 由于有新的成员加入,默 ...