昨天用vim练了一道大水题,今天特地找了道稍难一点的题。不过也不是很难,简单的计算几何而已。练习用vim编码,用gdb调试,结果居然1A了,没调试。。。囧。。。

做法很简单,无非就是两种情况:①三个巫师构成一个钝角(极限情况是直角)三角形,那么所画的圆应该是钝角所对边为直径的圆;②三个巫师构成一个锐角三角形,那么所画的圆应该是三角形的外接圆。

就这样纸,上了点模板,代码如下:

/*
* Author : ben
*/
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <functional>
#include <numeric>
#include <cctype>
using namespace std;
typedef struct MyPoint {
double x;
double y;
MyPoint(double xx, double yy) {
x = xx;
y = yy;
}
MyPoint() {
x = y = ;
}
}MyPoint; typedef struct MyLine {
MyPoint a, b;
} MyLine;
MyPoint intersection(MyLine u, MyLine v) {
MyPoint ret = u.a;
double t = ((u.a.x - v.a.x) * (v.a.y - v.b.y)
- (u.a.y - v.a.y) * (v.a.x - v.b.x))
/ ((u.a.x - u.b.x) * (v.a.y - v.b.y)
- (u.a.y - u.b.y) * (v.a.x - v.b.x));
ret.x += (u.b.x - u.a.x) * t;
ret.y += (u.b.y - u.a.y) * t;
return ret;
}
//外心
MyPoint circumcenter(MyPoint a, MyPoint b, MyPoint c) {
MyLine u, v;
u.a.x = (a.x + b.x) / ;
u.a.y = (a.y + b.y) / ;
u.b.x = u.a.x - a.y + b.y;
u.b.y = u.a.y + a.x - b.x;
v.a.x = (a.x + c.x) / ;
v.a.y = (a.y + c.y) / ;
v.b.x = v.a.x - a.y + c.y;
v.b.y = v.a.y + a.x - c.x;
return intersection(u, v);
}
typedef struct MyCircle {
MyPoint p;
double r;
}MyCircle; inline double dis(const MyPoint &p1, const MyPoint &p2) {
return (p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y);
} MyCircle getCircle(MyPoint ps[]) {
MyCircle ret;
ret.r = -;
for(int i = ; i < ; i++) {
MyPoint a = ps[i % ];
MyPoint b = ps[(i + ) % ];
MyPoint c = ps[(i + ) % ];
double x = (a.x + b.x) / ;
double y = (a.y + b.y) / ;
MyPoint t = MyPoint(x, y);
double r = dis(a, b) / ;
double temp = dis(t, c);
if(temp <= r) {
ret.r = r;
ret.p = t;
}
}
if(ret.r != -) {
return ret;
}
ret.p = circumcenter(ps[], ps[], ps[]);
ret.r = dis(ret.p, ps[]);
return ret;
} int main() {
// freopen("data.in", "r", stdin);
int T;
double x, y;
scanf("%d", &T);
MyPoint wizards[];
MyPoint muggle;
for(int t = ; t <= T; t++) {
for(int i = ; i < ; i++) {
scanf("%lf%lf", &x, &y);
wizards[i] = MyPoint(x, y);
}
scanf("%lf%lf", &x, &y);
muggle = MyPoint(x, y);
MyCircle c = getCircle(wizards);
double d = dis(muggle, c.p);
if(d <= c.r) {
printf("Case #%d: Danger\n", t);
} else {
printf("Case #%d: Safe\n", t);
}
}
return ;
}

hdu 4720 计算几何简单题的更多相关文章

  1. HDOJ/HDU 2568 前进(简单题)

    Problem Description 轻松通过墓碑,进入古墓后,才发现里面别有洞天. 突然,Yifenfei发现自己周围是黑压压的一群蝙蝠,个个扇动翅膀正准备一起向他发起进攻! 形势十分危急! 好在 ...

  2. HDU 1753 大明A+B(字符串模拟,简单题)

    简单题,但要考虑一些细节: 前导0不要,后导0不要,小数长度不一样时,有进位时,逆置处理输出 然后处理起来就比较麻烦了. 题目链接 我的代码纯模拟,把小数点前后分开来处理,写的很繁杂,纯当纪念——可怜 ...

  3. (hdu 简单题 128道)平方和与立方和(求一个区间的立方和和平方和)

    题目: 平方和与立方和 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total ...

  4. HDU 6106 17多校6 Classes(容斥简单题)

    Problem Description The school set up three elective courses, assuming that these courses are A, B, ...

  5. HDU 6463.超级无敌简单题-卡边界的暴力 (“字节跳动-文远知行杯”广东工业大学第十四届程序设计竞赛)

    超级无敌简单题 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Sub ...

  6. Least Common Multiple (HDU - 1019) 【简单数论】【LCM】【欧几里得辗转相除法】

    Least Common Multiple (HDU - 1019) [简单数论][LCM][欧几里得辗转相除法] 标签: 入门讲座题解 数论 题目描述 The least common multip ...

  7. BZOJ 2683: 简单题

    2683: 简单题 Time Limit: 50 Sec  Memory Limit: 128 MBSubmit: 913  Solved: 379[Submit][Status][Discuss] ...

  8. 【BZOJ-1176&2683】Mokia&简单题 CDQ分治

    1176: [Balkan2007]Mokia Time Limit: 30 Sec  Memory Limit: 162 MBSubmit: 1854  Solved: 821[Submit][St ...

  9. Bzoj4066 简单题

    Time Limit: 50 Sec  Memory Limit: 20 MBSubmit: 2185  Solved: 581 Description 你有一个N*N的棋盘,每个格子内有一个整数,初 ...

随机推荐

  1. [优先队列]HDOJ5360 Hiking

    题意:有n个人,每个人有两个参数$l$和$r$ 邀请他们去hiking, 当  当前已经邀请到的人数大于等于$l$,并且小于等于$r$,那么这个人就会去 问最多能邀请到几个人 并输出 依次要邀请的人的 ...

  2. hdu2010

    //很闲,刷水..... http://acm.hdu.edu.cn/showproblem.php?pid=2010 #include<iostream> #include<std ...

  3. 从svn删除文件夹和文件

    由于项目开始放在自己项目组的一个服务器上,而且svn也是自己在该服务器上搭建的,但是不知道是什么原因,svn上的代码被误删了.为了更稳定地使用svn,所以使用公司的svn来管理代码. 运维将不是最新版 ...

  4. 专家谈国产CPU最新发展态势:需强化标准建设(很全面)

    一.国产CPU发展现状与成就 国内已开启多技术路线并行的CPU技术产业新格局.在国家科技重大专项和国家级集成电路产业投资资金的推动之下,我国CPU产品技术研发已进入多技术路线同步推进的高速发展阶段,并 ...

  5. Apollo,Python,Delphi与Oracle之间的神话关系

    在希腊历史上Delphi曾被认为是世界的中心,Apollo杀死Python后将其据为己有,在其神庙上刻有Oracle,曰:Γνωθι δεαυτόν (认识你自己自身关怀,Cognosce te ip ...

  6. vss的ss.ini丢失或损坏导致的vss无法登录错误

    vss的ss.ini丢失或损坏导致的vss无法登录错误 Written in 2007-07-03 18:17 在vss使用过程中,不知道什么原因,会导至vss目录中的ss.ini文件损坏,此文件位于 ...

  7. Android ActionBar的Overlay模式如何不遮盖顶部内容的问题

    关于actionbar的overlay模式请参考 如何让android的actionbar浮动且透明 一文.这篇文章讲的是如何在这种模式下让actionbar不遮住顶部的内容. 这 一般是这样的场景, ...

  8. Spring Boot实现一个监听用户请求的拦截器

    项目中需要监听用户具体的请求操作,便通过一个拦截器来监听,并继续相应的日志记录 项目构建与Spring Boot,Spring Boot实现一个拦截器很容易. Spring Boot的核心启动类继承W ...

  9. 写出完美论文的十个技巧10 Tips for Writing the Perfect Paper

    10 Tips for Writing the Perfect Paper Like a gourmet meal or an old master painting, the perfect col ...

  10. Android开发之定义接口暴露数据

    写了一个网络请求的工具类,然后想要获取到网络请求的结果,在网络工具类中写了一个接口,暴露除了请求到的数据 代码: package com.lijingbo.knowweather.utils; imp ...