BZOJ 1336 Balkan2002 Alien最小圆覆盖
来源:互联网 发布:江苏知原药业怎么样 编辑:程序博客网 时间:2024/05/16 16:02
题目大意:最小圆覆盖。
思路:再拍一份模板。做法见:http://blog.csdn.net/jiangyuze831/article/details/43950601
CODE:
#define _CRT_SECURE_NO_WARNINGS#include <cmath>#include <cstdio>#include <cstring>#include <iomanip>#include <iostream>#include <algorithm>#define MAX 100010using namespace std;struct Point{double x,y;Point(double _,double __):x(_),y(__) {}Point() {}Point operator +(const Point &a)const {return Point(x + a.x,y + a.y);}Point operator -(const Point &a)const {return Point(x - a.x,y - a.y);}Point operator *(double a)const {return Point(x * a,y * a);}void Read() {scanf("%lf%lf",&x,&y);}}point[MAX];inline double Cross(const Point &p1,const Point &p2){return p1.x * p2.y - p1.y * p2.x;}inline double Calc(const Point &p1,const Point &p2){return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));}inline Point Mid(const Point &p1,const Point &p2){return Point((p1.x + p2.x) / 2,(p1.y + p2.y) / 2);}inline Point Change(const Point &v){return Point(-v.y,v.x);}struct Circle{Point o;double r;Circle(const Point &_,double __):o(_),r(__) {}Circle() {}bool InCircle(const Point &p) {return Calc(o,p) <= r;}};struct Line{Point p,v;Line(const Point &_,const Point &__):p(_),v(__) {}Line() {}};inline Point GetIntersection(const Line &l1,const Line &l2){Point u = l1.p - l2.p;double t = Cross(l2.v,u) / Cross(l1.v,l2.v);return l1.p + l1.v * t;}int points;int main(){cin >> points;for(int i = 1; i <= points; ++i)point[i].Read();random_shuffle(point + 1,point + points + 1);Circle now(point[1],.0);for(int i = 2; i <= points; ++i)if(!now.InCircle(point[i])) {now = Circle(point[i],.0);for(int j = 1; j < i; ++j)if(!now.InCircle(point[j])) {now = Circle(Mid(point[i],point[j]),Calc(point[i],point[j]) / 2);for(int k = 1; k < j; ++k)if(!now.InCircle(point[k])) {Line l1(Mid(point[i],point[j]),Change(point[j] - point[i]));Line l2(Mid(point[j],point[k]),Change(point[k] - point[j]));Point intersection = GetIntersection(l1,l2);now = Circle(intersection,Calc(intersection,point[i]));}}}cout << fixed << setprecision(10) << now.r << '\n' << now.o.x << ' ' << now.o.y << endl;return 0;}
0 0
- BZOJ 1336 Balkan2002 Alien最小圆覆盖
- BZOJ 1336 [Balkan2002]Alien最小圆覆盖
- BZOJ 1336([Balkan2002]Alien最小圆覆盖-最小覆盖圆)
- 【BZOJ 1336&1337】 [Balkan2002]Alien最小圆覆盖
- BZOJ 1336 Balkan2002 Alien最小圆覆盖 随机增量法
- BZOJ 1336: [Balkan2002]Alien最小圆覆盖 随机增量法
- BZOJ 1336: [Balkan2002]Alien最小圆覆盖 随机增量法
- bzoj 1336/bzoj 1337: [Balkan2002]Alien最小圆覆盖 随机增量法
- [BZOJ 1336/1337][Balkan2002]Alien最小圆覆盖:随机增量法
- 【Balkan2002】【BZOJ1336】Alien最小圆覆盖
- BZOJ1336 [Balkan2002]Alien最小圆覆盖
- BZOJ1336&1337:[Balkan2002]Alien最小圆覆盖
- [BZOJ1336][Balkan2002]Alien最小圆覆盖(最小圆覆盖)
- bzoj1336: [Balkan2002]Alien最小圆覆盖&&1337: 最小圆覆盖
- [随机增量法 最小圆覆盖] BZOJ 1366 [Balkan2002]Alien最小圆覆盖 & 1337 最小圆覆盖 & 2823 [AHOI2012]信号塔
- BZOJ 1336 & 1337 最小圆覆盖
- BZOJ 1336&1337最小圆覆盖
- BZOJ 1337 最小圆覆盖
- 菜鸟学C的一些感悟
- Linux 单片机
- 使用c3p0与DBCP连接池,造成的MySql 8小时问题解决方案
- 图论简介
- 代码复用
- BZOJ 1336 Balkan2002 Alien最小圆覆盖
- 【融云常见问题】数据库位置
- Ubuntu下配置sun jdk1.6
- 利用expect script实现ssh免密码登录
- Java虚拟机(JVM)中的内存设置详解
- 发送http请求的代码实现
- 使用Nexus搭建Maven私服
- 10个学习Android开发的网站推荐
- 经典学经:笨人学数学的方法