题意略。

思路:这个题的思路非常诡异。由于题目保证存在这样一个圆,那么每个点在这个圆上的概率是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. 关于C#多线程、易失域、锁的分享

    一.多线程 windows系统是一个多线程的操作系统.一个程序至少有一个进程,一个进程至少有一个线程.进程是线程的容器,一个C#客户端程序开始于一个单独的线程,CLR(公共语言运行库)为该进程创建了一 ...

  2. DAX 第六篇:统计函数

    统计函数用于创建聚合,对数据进行统计分析.在使用统计函数时,必须考虑到数据模型,表之间关系,数据重复等因素,一般都会搭配过滤函数实现数据的提取和分析. 统计量一般是:均值.求和.计数.最大值.最小值. ...

  3. mysql 不同版本下 group by 组内排序的差异

    最近发现网上找的 group by 组内排序语句在不同的mysql版本中结果不一样.   建表语句:   SET FOREIGN_KEY_CHECKS=0;   -- ---------------- ...

  4. java连接mysql数据库jdbc

    jdbc.driver = com.mysql.jdbc.Driverjdbc.url = jdbc:mysql://localhost:3306/数据库名jdbc.username = rootjd ...

  5. 模块购物商城和ATM机代码:

    http://outofmemory.cn/python/video/let-us-python/ python为程序员服务  快来加入群[python爬虫交流群](群号570070796),发现精彩 ...

  6. Mac Android 配置环境变量

    进入终端,输入以下命令: cd ~ touch .bash_profile //没有该文件的话新建一个 vi .bash_profile //vim 形式打开 输入内容jdk变量配置内容: expor ...

  7. ios开发--给应用添加新的字体的方法

    1.网上搜索字体文件(后缀名为.ttf,或.odf) 2.把字体库导入到工程的resouce中 3.在程序添加以下代码 输出所有字体 NSArray *familyNames = [UIFont fa ...

  8. HiveQL DDL 常用QL示例资料

    hive-version2.1.1 DDL操作 Create/Drop/Alter/Use Database 创建数据库 //官方指导 CREATE (DATABASE|SCHEMA) [IF NOT ...

  9. dotnetcore 与 hbase 之二——thrift 客户端的制作

    说明 在上一篇文章dotnetcore 与 hbase 之一--hbase 环境准备结束后,我们已经有了 hbase 数据库环境.接下来就可以利用 thrift 生成 c# hbase 客户端了.如果 ...

  10. java支付宝app支付-代码实现

    1.我们需要在支付宝商户平台配置好,取到四个参数如下(这是支付宝官方配置地址):https://www.cnblogs.com/fuzongle/p/10217144.html 合作身份者ID:123 ...