#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mk make_pair
#define PLL pair<LL, LL>
#define PLI pair<LL, int>
#define PII pair<int, int>
#define SZ(x) ((int)x.size())
#define ull unsigned long long
using namespace std; const int N = 2e5 + ;
const int inf = 0x3f3f3f3f;
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + ;
const double eps = 1.1e-4;
const double PI = acos(-); struct Point {
double x, y;
Point(double x = , double y = ) : x(x), y(y) { }
};
typedef Point Vector; int dcmp(double x) {
if(fabs(x) < eps) return ;
else return x < ? - : ;
} Point operator + (Vector A, Vector B) {return Point(A.x + B.x, A.y + B.y);}
Point operator - (Vector A, Vector B) {return Point(A.x - B.x, A.y - B.y);}
Point operator * (Vector A, double p) {return Point(A.x * p, A.y * p);}
Point operator / (Vector A, double p) {return Point(A.x / p, A.y / p);}
bool operator < (const Vector &A, const Vector &B) {return A.y < B.y || (A.y == B.y && A.x < B.x);}
bool operator == (const Vector &A, const Point &B) {return dcmp(A.x - B.x) == && dcmp(A.y - B.y) == ;}
double Dot(Vector A, Vector B) {return A.x * B.x + A.y * B.y;}
double Length(Vector A) {return sqrt(Dot(A, A));}
double Angle(Vector A, Vector B) {return acos(Dot(A, B) / Length(A) / Length(B));}
double Cross(Vector A, Vector B) {return A.x * B.y - A.y * B.x;}
double Area2(Point A, Point B, Point C) {return Cross(B - A, C - A);} Vector Rotate(Vector A, double rad) {
return Vector(A.x*cos(rad)-A.y*sin(rad), A.x*sin(rad)+A.y*cos(rad));
} double dist(const Point& a, const Point &b) {
return sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y));
} int n;
double r, R;
Point p[N]; Point GetCircleCenter(Point A, Point B, Point C) {
Point o;
double a1 = B.x-A.x, b1 = B.y-A.y, c1 = (a1*a1+b1*b1)/;
double a2 = C.x-A.x, b2 = C.y-A.y, c2 = (a2*a2+b2*b2)/;
double d = a1*b2-a2*b1;
o.x=A.x+(c1*b2-c2*b1)/d;
o.y=A.y+(a1*c2-a2*c1)/d;
return o;
} void MinPointCoverByCircle(Point *p, int n, Point &o, double &r) {
random_shuffle(p, p+n);
o = p[], r = ;
for(int i = ; i < n; i++) {
if(dist(p[i], o) > r + eps) {
o = p[i]; r = ;
for(int j = ; j < i; j++) {
if(dist(p[j], o) > r + eps) {
o.x = (p[i].x+p[j].x)/;
o.y = (p[i].y+p[j].y)/;
r = dist(p[j], o);
for(int k = ; k < j; k++) {
if(dist(p[k], o) > r + eps) {
o = GetCircleCenter(p[i], p[j], p[k]);
r = dist(p[i], o);
}
}
}
}
}
}
} int main() {
// freopen("robots.in", "r", stdin);
int T; scanf("%d", &T);
while(T--) {
scanf("%d%lf%lf", &n, &R, &r); n++;
p[] = Point(, );
for(int i = ; i < n; i++) {
double x, y; scanf("%lf%lf", &x, &y);
p[i] = p[i-] + Point(x, y);
}
sort(p, p+n);
n = unique(p, p+n)-p;
Point o;
MinPointCoverByCircle(p, n, o, r);
printf("%.12f %.12f\n", -o.x, -o.y);
}
return ;
}
/*
*/

最小圆覆盖 gym-102006 I的更多相关文章

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

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

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

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

  3. hdu3007Buried memory(最小圆覆盖)

    链接 普通的暴力复杂度达到O(n^4),对于这题肯定是不行的. 解法:随机增量算法 参考http://www.2cto.com/kf/201208/149602.html algorithm:A.令C ...

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

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

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

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

  6. 最小圆覆盖 hdu 3007

    今天学习了一下最小圆覆盖, 看了一下午都没看懂, 晚上慢慢的摸索这代码,接合着别人的讲解, 画着图跟着代码一步一步的走着,竟然有些理解了. 最小圆覆盖: 给定n个点, 求出半径最小的圆可以把这些点全部 ...

  7. bzoj1336: [Balkan2002]Alien最小圆覆盖

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1336 1336: [Balkan2002]Alien最小圆覆盖 Time Limit: 1 ...

  8. 【做题】POI2011R1 - Plot——最小圆覆盖&倍增

    原文链接 https://www.cnblogs.com/cly-none/p/loj2159.html 题意:给出\(n\)个点,你需要按编号将其划分成不超过\(m\)段连续的区间,使得所有每个区间 ...

  9. 【BZOJ2823】[AHOI2012]信号塔(最小圆覆盖)

    [BZOJ2823][AHOI2012]信号塔(最小圆覆盖) 题面 BZOJ 洛谷 相同的题: BZOJ1 BZOJ2 洛谷 题解 模板题... #include<iostream> #i ...

  10. Gym.102006:Syrian Collegiate Programming Contest(寒假自训第11场)

    学习了“叙利亚”这个单词:比较温和的一场:几何的板子eps太小了,坑了几发. A .Hello SCPC 2018! 题意:给定一个排列,问它是否满足,前面4个是有序的,而且前面4个比后面的都小. 思 ...

随机推荐

  1. SourceTree使用SSH克隆码云项目

    SourceTree使用SSH克隆码云项目 觉得有用的话,欢迎一起讨论相互学习~Follow Me SourceTree使用SSH克隆码云项目 参考文献 https://blog.csdn.net/q ...

  2. MESS-配置

    Author:KillerLegend From:http://www.cnblogs.com/killerlegend/p/3824989.html Date:2014.7.4 Part A 第一部 ...

  3. Nginx+tomcat 负载均衡

      一.系统版本 Nginx使用版本.tomcat使用版本: Nginx:nginx-1.10.2.tar.gz Java :Java version: 1.8.0_60, vendor: Oracl ...

  4. css文字超出显示省略号

    单号: white-space:nowrap; overflow:hidden; text-overflow:ellipsis; 多行: word-break: break-all; text-ove ...

  5. 兼容firefox,ie,谷歌,阻止浏览器冒泡事件,Firefox不支持event解决方法

    兼容firefox,ie,谷歌,阻止浏览器冒泡事件,Firefox不支持event解决方法 // 获取事件function getEvent(){ if(window.event) {return w ...

  6. 搭建zookeeper单机版以及简单命令的使用

    1:创建目录 #数据目录dataDir=/opt/hadoop/zookeeper-3.3.5-cdh3u5/data#日志目录dataLogDir=/opt/hadoop/zookeeper-3.3 ...

  7. 【leetcode 简单】 第五十八题 计数质数

    统计所有小于非负整数 n 的质数的数量. 示例: 输入: 10 输出: 4 解释: 小于 10 的质数一共有 4 个, 它们是 2, 3, 5, 7 . class Solution: def cou ...

  8. c++ new 和delete

    c++中new和delete的使用方法 new和delete运算符用于动态分配和撤销内存的运算符 new用法: 1.     开辟单变量地址空间 1)new int;  //开辟一个存放数组的存储空间 ...

  9. 信息安全学习笔记--XSS

    一.XSS简介 XSS (Cross Site Scripting)是一种经常出现在web应用中的计算机安全漏洞,它允许恶意web用户将代码植入到提供给其它用户使用的页面中.比如这些代码包括HTML代 ...

  10. 关于maven环境下使用pom.xml引入包名.lastUpdate包的解决办法

    今天在导入POI-OOXML的时候总是缺失xmlbeans包,而且刷新pom文件总是生成一个lastupdate文件,大小为1KB,终于找到解决办法. 1.首先删除想要的jar包所在文件夹内的所有 . ...