题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4720

  先两两点之间枚举,如果不能找的最小的圆,那么求外心即可。。

 //STATUS:C++_AC_0MS_292KB
#include <functional>
#include <algorithm>
#include <iostream>
//#include <ext/rope>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
//#pragma comment(linker,"/STACK:102400000,102400000")
//using namespace __gnu_cxx;
//define
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define PI acos(-1.0)
//typedef
typedef __int64 LL;
typedef unsigned __int64 ULL;
//const
const int N=;
const int INF=0x3f3f3f3f;
const int MOD=,STA=;
const LL LNF=1LL<<;
const double EPS=1e-;
const double OO=1e60;
const int dx[]={-,,,};
const int dy[]={,,,-};
const int day[]={,,,,,,,,,,,,};
//Daily Use ...
inline int sign(double x){return (x>EPS)-(x<-EPS);}
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> inline T lcm(T a,T b,T d){return a/d*b;}
template<class T> inline T Min(T a,T b){return a<b?a:b;}
template<class T> inline T Max(T a,T b){return a>b?a:b;}
template<class T> inline T Min(T a,T b,T c){return min(min(a, b),c);}
template<class T> inline T Max(T a,T b,T c){return max(max(a, b),c);}
template<class T> inline T Min(T a,T b,T c,T d){return min(min(a, b),min(c,d));}
template<class T> inline T Max(T a,T b,T c,T d){return max(max(a, b),max(c,d));}
//End int T; struct Point{
double x,y;
}p[]; double dist(Point a,Point b)
{
return sqrt( (a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y) );
} double sqr(double x){ return x * x; } void Ci(Point p0 , Point p1 , Point p2 , Point &cp)
{
double a1=p1.x-p0.x,b1 = p1.y - p0.y,c1 = (sqr(a1) + sqr(b1)) / ;
double a2=p2.x-p0.x,b2 = p2.y - p0.y,c2 = (sqr(a2) + sqr(b2)) / ;
double d = a1 * b2 - a2 * b1;
cp.x = p0.x + (c1 * b2 - c2 * b1) / d;
cp.y = p0.y + (a1 * c2 - a2 * c1) / d;
} int judge1(int& ok)
{
int i,j,k;
double d,r,lowr;
Point c,t;
lowr=OO;
for(i=;i<;i++){
for(j=;j<;j++){
if(i==j)continue;
r=dist(p[i],p[j])/;
t.x=(p[i].x+p[j].x)/;
t.y=(p[i].y+p[j].y)/;
for(k=;k==i || k==j;k++);
if(dist(t,p[k])<=r){
lowr=r;
c.x=t.x,c.y=t.y;
}
}
}
if(lowr==OO)return ;
if(dist(p[],c)<=lowr)ok=;
return ;
} int main(){
// freopen("in.txt","r",stdin);
int i,j,ca=,ok;
double r,d;
Point c;
scanf("%d",&T);
while(T--)
{
for(i=;i<;i++){
scanf("%lf%lf",&p[i].x,&p[i].y);
}
ok=;
if(judge1(ok));
else {
Ci(p[],p[],p[],c);
r=(c.x-p[].x)*(c.x-p[].x)+(c.y-p[].y)*(c.y-p[].y);
d=(c.x-p[].x)*(c.x-p[].x)+(c.y-p[].y)*(c.y-p[].y);
if(d<=r)ok=;
} printf("Case #%d: %s\n",ca++,ok?"Danger":"Safe");
}
return ;
}

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/Oth ...

  2. HDU 4720 Naive and Silly Muggles (简单计算几何)

    Naive and Silly Muggles Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/ ...

  3. HDU 4720 Naive and Silly Muggles 2013年四川省赛题

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4720 题目大意:给你四个点,用前三个点绘制一个最小的圆,而这三个点必须在圆上或者在圆内,判断最一个点如 ...

  4. HDU 4720 Naive and Silly Muggles 平面几何

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4720 解题报告:给出一个三角形的三个顶点坐标,要求用一个最小的圆将这个三个点都包含在内,另外输入一个点 ...

  5. 计算几何 HDOJ 4720 Naive and Silly Muggles

    题目传送门 /* 题意:给三个点求它们的外接圆,判断一个点是否在园内 计算几何:我用重心当圆心竟然AC了,数据真水:) 正解以后补充,http://www.cnblogs.com/kuangbin/a ...

  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 (计算几何)

    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. Naive and Silly Muggles hdu4720

    Naive and Silly Muggles Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/ ...

随机推荐

  1. QTP之对测试用例的自动化过程的分解

    第一部分:自动化一个测试用例 当你要开始自动化一个测试用例的时候,有一些重要的事情需要完成.当你完成所有这些事情的时候,测试脚本的自动化也随之完成. 在这里,我们将首先在大部分的自动化测试用例里找出所 ...

  2. python - PipeMapRed.waitOutputThreads(): subprocess failed with code 1

    hadoop上执行mapreduce streaming python程序报错, 报错详细信息为 python - PipeMapRed.waitOutputThreads(): subprocess ...

  3. 学习webView控件使用

    WebView 对象用于网页显示使用,简单的学习并使用了一下. 1.首先在 layout 中摆一个全屏的 webview 控件 (main.xml ) <?xml version="1 ...

  4. .Net MVC API初试

    新建.net mvc api项目后,直接运行,默认会访问http://localhost:xxxx/Home/Index页面,这个页面不是要访问的API页面. 从项目的目录可以看出,默认的API页面访 ...

  5. hibernate 中id生成策略

    数据库的设计和操作中,我们通常会给表建立主键. 主键,可以分为自然主键和代理主键. 自然主键表示:采用具有业务逻辑含义的字段作为表的主键.比如在用户信息表中,采用用户的身份证号码作为主键.但是这样一来 ...

  6. poshytip两个实用示例

    <html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> < ...

  7. Struts2配置

    1.      设定server a)      window– preferences – myeclipse – servers – tomcat – 6.x b)      选择tomcat h ...

  8. java后台调用HttpURLConnection类模拟浏览器请求(一般用于接口调用)

    项目开发中难免遇到外部接口的调用,小生今天初次接触该类,跟着API方法走了一遍,如有不对的地方,还请哆哆指正,拜谢! 1 package com.cplatform.movie.back.test; ...

  9. ActionBarSherlock的学习笔记(三) ------------ ActionBarSherlock中的overflow及item的点击事件

    定义一个自定义的ActionBar的title,并添加一个overflow的Action   Item. 代码实现 如下  : import android.os.Bundle; import and ...

  10. Mybatis学习——一对多关联表查询

    1.实体类 public class Student { private int id; private String name; } public class Classes { private i ...