Country Meow
2024-08-29 05:41:33
Country Meow
和这基本一样 https://www.cnblogs.com/Fighting-sh/p/9809518.html
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
using namespace std; struct Point{
double x,y,z;
}p[]; double dist(Point a,Point b){
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)+(a.z-b.z)*(a.z-b.z));
} double ac(int n){
double ans=1e9;
Point tmp;
tmp.x=tmp.y=tmp.z=;;
int s=;
double step=;
double esp=0.0000001;
while(step>esp){
for(int i=;i<=n;i++){
if(dist(tmp,p[s])<dist(tmp,p[i])) s=i;
}
double Dist=dist(tmp,p[s]);
ans=min(ans,Dist);
tmp.x+=(p[s].x-tmp.x)/Dist*step;
tmp.y+=(p[s].y-tmp.y)/Dist*step;
tmp.z+=(p[s].z-tmp.z)/Dist*step;
step*=0.999;
}
return ans;
} int main(){
int n;
while(~scanf("%d",&n)){
if(!n) break;
for(int i=;i<=n;i++){
scanf("%lf %lf %lf",&p[i].x,&p[i].y,&p[i].z);
}
double ans=ac(n);
printf("%.5f\n",ans);
}
}
最新文章
- android 利用线程刷新UI方法
- ubuntu 设置 NAT 转发
- poj 2923 状压dp+01背包
- Qt 串口学习3
- Python开发【第一篇】:目录
- Html中版权符号的字体选择问题(如何让版权符号更美观)
- java中怎么判断一个字符串中包含某个字符或字符串
- CreateMutex
- 苹果浏览器Safari对JS函数库中newDate()函数中的参数的解析中不支持形如“2020-01-01”形式
- python函数(2):函数进阶
- expect免互交 常用编辑文本
- zsh 缺省输入设置
- 转 Ubuntu16.04+QT4.8.7开发环境搭建
- thymeleaf:访问list,map等
- 053 kafka自带的生产者与消费者测试
- 聊聊setTimeout和setInterval线程
- python五十八课——正则表达式(分组)
- SSH框架总结(环境搭建+框架分析+实例源码下载)
- iOS编程(双语版)-视图-Frame/Bounds/Center
- 神奇的照片修复术,这才是 PS 的正确打开方式!