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 解题报告:给出一个三角形的三个顶点坐标,要求用一个最小的圆将这个三个点都包含在内,另外输入一个点 ...
随机推荐
- 官方问答--微信小程序常见FAQ (17.8.21-17.8.27)
给提问的开发者的建议:提问之前先查询 文档.通过社区右上角搜索搜索已经存在的问题. 写一个简明扼要的标题,并且正文描述清楚你的问题. 提交 BUG:需要带上基础库版本号,设备信息(iOS, Andro ...
- EAGO科技人工智能+澳洲MSPL外汇平台招商
天下财经 首席运营商 EAGO外汇人工智能简介:我们将历史数据导入算法引擎,加入因子(外汇中使用的各种技术指标及各个国家的货币政策等)让计算机通过二元遗传基因.深度神经网络等算法,由机器自主深度学习. ...
- github如何添加ssh
1.运行git Bash 输入如下命令: $ cd ~/.ssh $ ls 输入这2个命令 ,我们可以看到 id_rsa.pub 或 id_dsa.pub 这2个文件已经存在了,id_rsa 是私钥, ...
- QT creator编程C++第一步,说“Hello world!”
这个学期选了计算机学院的<数字图像处理>,正好和我的图像识别项目有所关联,老师说不能用MATLAB来做,这让我一个没学过C++的孩纸欲哭无泪. 只好求助计算机学院的大佬,自学C++. 大佬 ...
- Entity Framework Core Like 查询揭秘
在Entity Framework Core 2.0中增加一个很酷的功能:EF.Functions.Like(),最终解析为SQL中的Like语句,以便于在 LINQ 查询中直接调用. 不过Entit ...
- java 比较几种常见循环方式的优劣
详见:http://blog.yemou.net/article/query/info/tytfjhfascvhzxcyt224 我们常用for循环,foeach,while等作为循环list或者数组 ...
- [ASP.NET MVC]笔记(四 UnobtruSive AJAX和客户端验证
UnobtruSive AJAX和客户端验证 ASP.NET MVC 已经默认开启非侵入试js和客户端验证,在web.config可以看到如下配置: <configuration> < ...
- NHibernate教程(11)--多对多关联查询
本节内容 多对多关系引入 多对多映射关系 多对多关联查询 1.原生SQL关联查询 2.HQL关联查询 3.Criteria API关联查询 结语 多对多关系引入 让我们再次回顾在第二篇中建立的数据模型 ...
- [转载]PS各个工具的字母快捷键和英文全名
原文地址:PS各个工具的字母快捷键和英文全名作者:Tycho 选框-Marquee(M) 移动-move(V) 套索-Lasso(L) 魔棒-Wand(W) 喷枪-in ...
- 结对编程-四则运算生成程序-GUI界面
201421123118 张中结 201421123098 胡丹丹 a.需求分析 这个程序做成GUI(可以是Windows PC 上的,也可以是Mac.Linux,web,手机上的),成为一个有基本功 ...