/**************************************************************
Problem: 1337
User: idy002
Language: C++
Result: Accepted
Time:4 ms
Memory:2372 kb
****************************************************************/ #include <cstdio>
#include <cmath>
#include <algorithm>
#define line(a,b) ((b)-(a))
#define eps 1e-10
#define N 100010
using namespace std; int sg( double x ) { return (x>-eps)-(x<eps); }
struct Vector {
double x, y;
Vector( double x=, double y= ):x(x),y(y){}
Vector operator+( const Vector &b ) const { return Vector(x+b.x,y+b.y); }
Vector operator-( const Vector &b ) const { return Vector(x-b.x,y-b.y); }
Vector operator*( double b ) const { return Vector(x*b,y*b); }
Vector operator/( double b ) const { return Vector(x/b,y/b); }
double operator^( const Vector &b ) const { return x*b.y-y*b.x; }
double len() { return sqrt(x*x+y*y); }
Vector nor() { return Vector(-y,x); }
};
typedef Vector Point;
Point inter( Point p, Vector u, Point q, Vector v ) {
return p+u*((line(p,q)^v)/(u^v));
}
struct Circle {
Point o;
double r;
Circle(){}
Circle( Point a ):o(a),r(){}
Circle( Point a, Point b ) {
o = (a+b)/;
r = (a-b).len()/;
}
Circle( Point a, Point b, Point c ) { // ab^bc != 0
Point p=(a+b)/, q=(b+c)/;
Vector u=(a-b).nor(), v=(b-c).nor();
o = inter(p,u,q,v);
r = (o-a).len();
}
bool contain( Point a ) {
return sg( (a-o).len() - r ) <= ;
}
}; int n;
Point pts[N]; int main() {
scanf( "%d", &n );
for( int i=; i<=n; i++ ) {
double x, y;
scanf( "%lf%lf", &x, &y );
pts[i] = Point(x,y);
}
random_shuffle( pts+, pts++n );
Circle c = Circle(pts[]);
for( int i=; i<=n; i++ ) {
if( c.contain(pts[i]) ) continue;
c = Circle(pts[i]);
for( int j=; j<i; j++ ) {
if( c.contain(pts[j]) ) continue;
c = Circle(pts[i],pts[j]);
for( int k=; k<j; k++ ) {
if( c.contain(pts[k]) ) continue;
c = Circle(pts[i],pts[j],pts[k]);
}
}
}
printf( "%.3lf\n", c.r );
}

题解见bzoj 1336

bzoj 1337 最小圆覆盖的更多相关文章

  1. BZOJ 1337: 最小圆覆盖1336: [Balkan2002]Alien最小圆覆盖(随机增量法)

    今天才知道有一种东西叫随机增量法就来学了= = 挺神奇的= = A.令ci为包括前i个点的最小圆,若第i+1个点无法被ci覆盖,则第i+1个点一定在ci+1上 B.令ci为包括前i个点的最小圆且p在边 ...

  2. bzoj 1336 最小圆覆盖

    最小圆覆盖 问题:给定平面上的一个点集,求半径最小的一个圆,使得点集中的点都在其内部或上面. 随机增量算法: 定义:点集A的最小圆覆盖是Circle(A) 定理:如果Circle(A)=C1,且a不被 ...

  3. bzoj2823: [AHOI2012]信号塔&&1336: [Balkan2002]Alien最小圆覆盖&&1337: 最小圆覆盖

    首先我写了个凸包就溜了 这是最小圆覆盖问题,今晚学了一下 先随机化点,一个个加入 假设当前圆心为o,半径为r,加入的点为i 若i不在圆里面,令圆心为i,半径为0 再重新从1~i-1不停找j不在圆里面, ...

  4. BZOJ 1336&1337最小圆覆盖

    思路: http://blog.csdn.net/commonc/article/details/52291822 (照着算法步骤写--) 已知三点共圆 求圆心的时候 就设一下圆心坐标(x,y) 解个 ...

  5. 【BZOJ-1336&1337】Alie最小圆覆盖 最小圆覆盖(随机增量法)

    1336: [Balkan2002]Alien最小圆覆盖 Time Limit: 1 Sec  Memory Limit: 162 MBSec  Special JudgeSubmit: 1573   ...

  6. 2018.07.04 BZOJ1336&&1337: Balkan2002Alien最小圆覆盖

    1336: [Balkan2002]Alien最小圆覆盖 1337: 最小圆覆盖 Time Limit: 1 Sec Memory Limit: 162 MBSec Special Judge Des ...

  7. Bzoj 1336&1337 Alien最小圆覆盖

    1336: [Balkan2002]Alien最小圆覆盖 Time Limit: 1 Sec  Memory Limit: 162 MBSec  Special Judge Submit: 1473  ...

  8. [BZOJ 3564] [SHOI2014] 信号增幅仪 【最小圆覆盖】

    题目链接:BZOJ - 3564 题目分析 求最小椭圆覆盖,题目给定了椭圆的长轴与 x 轴正方向的夹角,给定了椭圆长轴与短轴的比值. 那么先将所有点旋转一个角度,使椭圆长轴与 x 轴平行,再将所有点的 ...

  9. [BZOJ 1336] [Balkan2002] Alien最小圆覆盖 【随机增量法】

    题目链接:BZOJ - 1336 题目分析 最小圆覆盖有一个算法叫做随机增量法,看起来复杂度像是 O(n^3) ,但是可以证明其实平均是 O(n) 的,至于为什么我不知道= = 为什么是随机呢?因为算 ...

随机推荐

  1. Linux内存初始化【转】

    转自:http://www.cnblogs.com/super-king/p/3291120.html start_kernel -> setup_arch 在这个函数中我们主要看这几个函数. ...

  2. ProtocolBuffer 使用及 一些坑

    Protocol Buffers,是Google公司开发的一种数据描述语言,类似于XML能够将结构化数据序列化,可用于数据存储.通信协议等方面. ProtocolBuffer的优势 跨平台: Prot ...

  3. 使用脚本实现killproc的功能

    在shell提示符号下输入type killproc,会发现killproc实在 /sbin/目录下,通过man killproc可以查看这个脚本(姑且这么称为脚本)的用法,现在,把这个脚本的实现过程 ...

  4. docker centos:last 开启sshd 遇到的证书问题

    启动sshd: # /usr/sbin/sshd 一.问题描述 这时报以下错误: [root@ xxx/]# /usr/sbin/sshd Could not load host key: /etc/ ...

  5. Oracle 函数 “申请通过后,将该表中循环遍历到的所有内容插到另一个表中”

    create or replace function mcode_apply_insert_material(p_mca_no VARCHAR2, p_action VARCHAR2, p_wf_no ...

  6. MFC中CString.Format类详解

    在MFC程序中,使用CString来处理字符串是一个很不错的选择.CString既可以处理Unicode标准的字符串,也可以处理ANSI标准的字符串.CString的Format方法给我们进行字符串的 ...

  7. No.7 selenium学习之路之Alert弹窗

    Alert弹窗 弹窗是用工具选不到的~ 切换到alert driver.switch_to_alert() 新的语法:driver.switch_to.alert 注:新的语法不需要后面加括号 打印a ...

  8. js中的事件委托或是事件代理

    JavaScript(jQuery)中的事件委托 https://www.cnblogs.com/zhoushengxiu/p/5703095.html js中的事件委托或是事件代理详解 https: ...

  9. HDU 2609 How many(最小表示+set)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2609 题目大意: 题目大意有n个有01组成的字符串,每个字符串都代表一个项链,那么该字符串就是一个环状 ...

  10. Centos之目录处理命令

    linux中 关于目录 有几个重要概念 一个是 / 根目录  还有一个当前用户的家目录 比如 root用户的家目录是 /root  普通用户的家目录是/home/xxx 下 root登录 默认家目录 ...