题意略。

思路:这个题的思路非常诡异。由于题目保证存在这样一个圆,那么每个点在这个圆上的概率是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. DedeCms常用内容调用标签实例大全

    一.调用顶级栏目标签 <a href="{dede:global.cfg_cmsurl/}/" class="ahov">首页</a> ...

  2. cookbook_元编程

    1给函数添加一个包装 问题:给函数加一个外包装层,已添加额外的处理,例如,记录日志,计时统计等 解决方案:可以定义一个装饰器来包装函数 2编写装饰器时如何保存函数的元数据 问题:当一个函数被装饰器装饰 ...

  3. Java_转换流和缓冲流

    今日内容介绍 转换流 缓冲流 1 转换流 在学习字符流(FileReader.FileWriter)的时候,其中说如果需要指定编码和缓冲区大小时,可以在字节流的基础上,构造一个InputStreamR ...

  4. java课堂_动手动脑4

    1.请运行以下示例代码StringPool.java,查看其输出结果.如何解释这样的输出结果?从中你能总结出什么? 答:在Java中,内容相同的字串常量(“Hello”)只保存一份以节约内存,所以s0 ...

  5. 闯荡Ext-第一篇

    今天在网上找到了一本非常好的书:<Ext江湖>,这本书是由大漠穷秋大神写的,刚看到这本书的时候,心里面的那个激动劲啊,本来原先的时候心里面就一直念叨着想要学习Ext,但是苦于找不到好的资料 ...

  6. MyBatis之#{} and ${}

    #{} 和 ${} 之间最大的差别就是  #{}会在使用的时候被加上 ‘’ 引号, ${}直接传值,不做任何处理 1.#{}对传入的参数会做预编译,也就是会当做字符串来处理 select * from ...

  7. jQuery中的append中含有onClick的问题

    在jQuery中,当append中含有onClick时,点击事件无效果.需要在append完之后再额外绑定点击事件.

  8. [转载]关于ActiveMQ集群

    转载于 http://blog.csdn.net/nimmy/article/details/6247289 近日因工作关系,在研究JMS,使用ActiveMQ作为提供者,考虑到消息的重要,拟采用Ac ...

  9. 全球十大OTA 谁能有一席之地?

    全球十大OTA 谁能有一席之地? http://www.traveldaily.cn/article/78381/1 2014-03-05 来源:i黑马 随着旅游行业日新月异的发展,在线旅游网站的出现 ...

  10. ssm访问不了后台

    最近整理ssm,写完demo案例,无论如何都访问不了后台,百度了好多,终于解决了问题所在 先看页面信息: 因为一直报404错误,一直找路径是不是弄错了,或配置文件弄错了,仅仅这个配置文件都看了无数遍, ...