博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ZOJ 1450
阅读量:4689 次
发布时间:2019-06-09

本文共 1443 字,大约阅读时间需要 4 分钟。

最小圆覆盖

#include 
#include
#include
#include
using namespace std;const double eps=0.00000001;struct point { double x,y;}p[110];struct circle{ point cent; double rad;}cir;int n;double TriangleArea(point t1,point t2,point t3){ point p1,p2; p1.x=t1.x-t3.x; p1.y=t1.y-t3.y; p2.x=t2.x-t3.x; p2.y=t2.y-t3.y; return fabs(p1.x*p2.y-p2.x*p1.y)/2;}double dist(point p1,point p2){ return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));}void TriangleCircle(point ta,point tb,point tc){ double a=dist(ta,tb); double b=dist(tb,tc); double c=dist(tc,ta); cir.rad=(a*b*c)/TriangleArea(ta,tb,tc)/4; double xa=ta.x; double ya=ta.y; double xb=tb.x; double yb=tb.y; double xc=tc.x; double yc=tc.y; double c1=(xa*xa+ya*ya-xb*xb-yb*yb)/2; double c2=(xa*xa+ya*ya-xc*xc-yc*yc)/2; cir.cent.x=(c1*(ya-yc)-c2*(ya-yb))/((xa-xb)*(ya-yc)-(xa-xc)*(ya-yb)); cir.cent.y=(c1*(xa-xc)-c2*(xa-xb))/((ya-yb)*(xa-xc)-(ya-yc)*(xa-xb));}void slove(){ random_shuffle(p,p+n); cir.cent=p[0]; cir.rad=0; for(int i=1;i
cir.rad ){ cir.cent=p[i]; cir.rad=0; for(int j=0;j
cir.rad ){ cir.cent.x=(p[j].x+p[i].x)/2; cir.cent.y=(p[i].y+p[j].y)/2; cir.rad=dist(p[j],p[i])/2; for(int k=0;k
cir.rad ){ TriangleCircle(p[i],p[j],p[k]); } } } } } }}int main(){ while(scanf("%d",&n)!=EOF){ if(n==0) break; for(int i=0;i

  

转载于:https://www.cnblogs.com/jie-dcai/p/3885931.html

你可能感兴趣的文章
【BZOJ4592】[Shoi2015]脑洞治疗仪 线段树
查看>>
redis sentinel 读写分离
查看>>
团队项目(第五周)
查看>>
ElasticSearch6(三)-- Java API实现简单的增删改查
查看>>
选拔赛 I 点进来吧,这里有你想要的
查看>>
SQL 优化经验总结34条
查看>>
开源 视频会议 收藏
查看>>
核心J2EE模式 - 截取过滤器
查看>>
test1
查看>>
.net开源CMS
查看>>
你懂AI吗(1)
查看>>
双拼输入法
查看>>
CentOS7 中防火墙配置
查看>>
php扩展目录
查看>>
PageRank算法
查看>>
git的介绍和配置
查看>>
C 语言 习题 1-14
查看>>
密码锁
查看>>
值类型和引用类型区别,一看就懂
查看>>
UVa 11375 Matches
查看>>