题意略。

思路:这个题的思路非常诡异。由于题目保证存在这样一个圆,那么每个点在这个圆上的概率是1/2,我任选3个点,这3个点都在这个圆上的概率是1 / 8。

不都在这个圆上的概率是7 / 8,在这样选取30次后,还没有找到这个圆的概率是0.018,根据这个条件我们可以暴力验证。

详见代码:

#include<bits/stdc++.h>
#define maxn 100005
#define eps 1e-6
using namespace std; struct Point{
double x,y;
Point(double a = ,double b = ){
x = a,y = b;
}
}; Point store[maxn];
int T,n; Point circumcenter(Point a,Point b,Point c){
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;
return Point(a.x + (c1 * b2 - c2 * b1) / d,a.y + (a1 * c2 - a2 * c1) / d);
}
double dist(Point p1,Point p2){
double dx = p1.x - p2.x,dy= p1.y - p2.y;
return sqrt(dx * dx + dy * dy);
}
int sgn(double x,double y){
if(fabs(x - y) < eps) return ;
else if(x + eps < y) return -;
else return ;
} int main(){
scanf("%d",&T);
srand(time());
while(T--){
scanf("%d",&n);
for(int i = ;i < n;++i){
scanf("%lf%lf",&store[i].x,&store[i].y);
}
Point center;
double R;
if(n == ){
center = Point(store[].x + ,store[].y);
R = ;
}
else if( < n && n <= ){
center = Point((store[].x + store[].x) / ,(store[].y + store[].y) / );
R = dist(center,store[]);
}
else{
int cnt = ;
while(cnt < (n + ) / ){
cnt = ;
int s1 = rand() % n,s2 = rand() % n,s3 = rand() % n;
while(s1 == s2 || s1 == s3 || s2 == s3){
if(s1 == s2) s1 = rand() % n;
if(s1 == s3) s3 = rand() % n;
if(s2 == s3) s2 = rand() % n;
}
center = circumcenter(store[s1],store[s2],store[s3]);
R = dist(center,store[s1]);
for(int i = ;i < n;++i){
double r = dist(store[i],center);
if(sgn(r,R) == ) ++cnt;
}
}
}
printf("%lf %lf %lf\n",center.x,center.y,R);
}
return ;
}

HDU 6242的更多相关文章

  1. HDU - 6242 Geometry Problem (几何,思维,随机)

    Geometry Problem HDU - 6242 Alice is interesting in computation geometry problem recently. She found ...

  2. HDU 6242 Geometry Problem(计算几何 + 随机化)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6242 思路:当 n == 1 时 任取一点 p 作为圆心即可. n >= 2 && ...

  3. 2017 CCPC 哈尔滨站 HDU 6242

    Geometry Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Other ...

  4. HDU - 6242:Geometry Problem(随机+几何)

    Alice is interesting in computation geometry problem recently. She found a interesting problem and s ...

  5. hdu 6242 Geometry Problem

    Geometry Problem Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Other ...

  6. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  7. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  8. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  9. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

随机推荐

  1. Django REST Framework(DRF)_第二篇

    视图和路由 视图封装 第一次封装 ​ 上一篇最后我们对书籍表做了增删改查,那么如果现在我们有几十上百张表需要这样做呢?我们知道类的特性有封装,因此我们可以尝试进行封装下. from rest_fram ...

  2. docker学习ppt

    保存下学习资料

  3. LeetCode 解题目录

    0001. 两数之和(Java) 0003. 无重复字符的最长子串(Java) 0172. 阶乘后的零 (Java) 0287. 寻找重复数(Java)

  4. 备战金九银十,Java研发面试题(Spring、MySQL、JVM、Mybatis、Redis、Tomcat)[带答案],刷起来!

    八月在即,马上就是"金九银十",又是跳槽招聘季.咱们这行公认涨薪不如跳槽加的快.但不建议频繁跳槽,还是要学会融合团队,抓住每个机会提升技能. 苏先生在这里给大家整理了一套各大互联网 ...

  5. 【MySQL】日常小技巧汇总,更新中……

    创建表时修改自增主键,添加 AUTO_INCREMENT=<Number> ,例如: CREATE TABLE `table_name` ( `id` int(11) unsigned N ...

  6. 使用 OpenSSL为WindowsServer远程桌面(RDP)创建自签名证书 (Self-signed SSL certificate)

    前言 笔者查阅很多资料,才写成此文章,如有错误,请读者们及时提出. 一般大家使用远程桌面(Remote Desktop)连接Windows Server时,总会有一个警告提示,如图1 图1 出现此警告 ...

  7. Css3动画效果,彩色文字效果,超简单的loveHeart

    <!DOCTYPE html><html><head><meta charset="utf-8" /><title>Cs ...

  8. java实现发短信功能---腾讯云短信

    目录 java实现发短信功能 前言 开发环境 腾讯云 ---短信 代码 效果 结束语 java实现发短信功能 前言 如今发短信功能已经成为互联网公司的标配,本篇文章将一步步实现java发送短信 考察了 ...

  9. 下拉框spinner

    repositories { flatDir { dirs 'libs' //就是你放aar的目录地址 maven { url "https://jitpack.io" } }}d ...

  10. 60701BMP彩色图像转化为灰度及二值图像

    1 概述 多媒体技术是一门综合了多种学科的新技术,其涉及到计算机科学与技术.通信和网络技术.人工智能技术.微电子技术.数字信号处理.图形处 理技术.声像技术等诸多学科.许多新技术的不断出现和体验,带给 ...