Super Star

http://poj.org/problem?id=2069

Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 6486   Accepted: 1603   Special Judge

Description

During a voyage of the starship Hakodate-maru (see Problem 1406), researchers found strange synchronized movements of stars. Having heard these observations, Dr. Extreme proposed a theory of "super stars". Do not take this term as a description of actors or singers. It is a revolutionary theory in astronomy. 
According to this theory, starts we are observing are not independent objects, but only small portions of larger objects called super stars. A super star is filled with invisible (or transparent) material, and only a number of points inside or on its surface shine. These points are observed as stars by us.

In order to verify this theory, Dr. Extreme wants to build motion equations of super stars and to compare the solutions of these equations with observed movements of stars. As the first step, he assumes that a super star is sphere-shaped, and has the smallest possible radius such that the sphere contains all given stars in or on it. This assumption makes it possible to estimate the volume of a super star, and thus its mass (the density of the invisible material is known).

You are asked to help Dr. Extreme by writing a program which, given the locations of a number of stars, finds the smallest sphere containing all of them in or on it. In this computation, you should ignore the sizes of stars. In other words, a star should be regarded as a point. You may assume the universe is a Euclidean space.

Input

The input consists of multiple data sets. Each data set is given in the following format.


x1 y1 z1 
x2 y2 z2 
. . . 
xn yn zn

The first line of a data set contains an integer n, which is the number of points. It satisfies the condition 4 <= n <= 30.

The location of n points are given by three-dimensional orthogonal coordinates: (xi, yi, zi) (i = 1, ..., n). Three coordinates of a point appear in a line, separated by a space character. Each value is given by a decimal fraction, and is between 0.0 and 100.0 (both ends inclusive). Points are at least 0.01 distant from each other.

The end of the input is indicated by a line containing a zero.

Output

For each data set, the radius of the smallest sphere containing all given points should be printed, each in a separate line. The printed values should have 5 digits after the decimal point. They may not have an error greater than 0.00001.

Sample Input

  1. 4
  2. 10.00000 10.00000 10.00000
  3. 20.00000 10.00000 10.00000
  4. 20.00000 20.00000 10.00000
  5. 10.00000 20.00000 10.00000
  6. 4
  7. 10.00000 10.00000 10.00000
  8. 10.00000 50.00000 50.00000
  9. 50.00000 10.00000 50.00000
  10. 50.00000 50.00000 10.00000
  11. 0

Sample Output

  1. 7.07107
  2. 34.64102

最小球覆盖模板题,先任意选取一个点,然后找到一个离它最远的点,不断逼近

  1. #include<iostream>
  2. #include<cstdio>
  3. #include<cstring>
  4. #include<cmath>
  5. #include<string>
  6. #include<algorithm>
  7. #include<queue>
  8. #include<vector>
  9. #include<map>
  10. using namespace std;
  11.  
  12. struct Point{
  13. double x,y,z;
  14. }p[];
  15.  
  16. double dist(Point a,Point b){
  17. 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));
  18. }
  19.  
  20. double ac(int n){
  21. double ans=1e9;
  22. Point tmp;
  23. tmp.x=tmp.y=tmp.z=;;
  24. int s=;
  25. double step=;
  26. double esp=0.0000001;
  27. while(step>esp){
  28. for(int i=;i<=n;i++){
  29. if(dist(tmp,p[s])<dist(tmp,p[i])) s=i;
  30. }
  31. double Dist=dist(tmp,p[s]);
  32. ans=min(ans,Dist);
  33. tmp.x+=(p[s].x-tmp.x)/Dist*step;
  34. tmp.y+=(p[s].y-tmp.y)/Dist*step;
  35. tmp.z+=(p[s].z-tmp.z)/Dist*step;
  36. step*=0.99;
  37. }
  38. return ans;
  39. }
  40.  
  41. int main(){
  42. int n;
  43. while(~scanf("%d",&n)){
  44. if(!n) break;
  45. for(int i=;i<=n;i++){
  46. scanf("%lf %lf %lf",&p[i].x,&p[i].y,&p[i].z);
  47. }
  48. double ans=ac(n);
  49. printf("%.5f\n",ans);
  50. }
  51. }

Super Star(最小球覆盖)的更多相关文章

  1. POJ 2069 Super Star(计算几何の最小球包含+模拟退火)

    Description During a voyage of the starship Hakodate-maru (see Problem 1406), researchers found stra ...

  2. D.Country Meow 最小球覆盖 三分套三分套三分 && 模拟退火

    // 2019.10.3 // 练习题:2018 ICPC 南京现场赛 D Country Meow 题目大意 给定空间内 N 个点,求某个点到 N 个点的距离最大值的最小值.   思路 非常裸的最小 ...

  3. POJ 最小球覆盖 模拟退火

    最小球覆盖:用半径最小的球去覆盖所有点. 纯粹的退火算法,是搞不定的,精度不够,不然就会TLE,根本跑不出答案来. 任取一点为球心,然后一点点靠近最远点.其实这才是最主要的. 因为:4个点确定一个球, ...

  4. POJ2069 最小球覆盖 几何法和退火法

    对这种问题不熟悉的读者 可以先去看一看最小圆覆盖的问题 ZOJ1450 现在我们来看最小球覆盖问题POJ2069 题目很裸,给30个点 求能覆盖所有点的最小球的半径. 先给出以下几个事实: 1.对于一 ...

  5. 最小球覆盖——模拟退火&&三分套三分套三分

    题目 给出 $N(1 \leq N \leq 100)$ 个点的坐标 $x_i,y_i,z_i$($-100000 \leq x_i,y_i,z_i \leq 100000$),求包围全部点的最小的球 ...

  6. 使用super调用被子类覆盖的父类方法

    1.没有super方法 /* * 子类方法覆盖父类方法,用super方法可以调用父类被覆盖的方法 */ class fruit{ public fruit() { System.out.println ...

  7. perl 使用SUPER类来访问覆盖的方法

    有时候,你希望一个衍生类的方法表现得象基类中的某些方法的封装器 这就是 SUPER 伪类提供便利的地方.它令你能够调用一个覆盖了的基类方法,而不用声明 是哪个类定义了该方 法.(注:不要把这个和第十一 ...

  8. Super不要在Super构造器中调用覆盖方法

    import java.util.Date; public class Super{ public Super(){ System."); overrideMe(); System.&quo ...

  9. 【模拟退火】poj2069 Super Star

    题意:让你求空间内n个点的最小覆盖球. 模拟退火随机走的时候主要有这几种走法:①随机旋转角度. ②直接不随机,往最远的点的方向走,仅仅在尝试接受解的时候用概率.(最小圆/球覆盖时常用) ③往所有点的方 ...

随机推荐

  1. 服务注册发现consul之五:Consul移除失效服务的正确姿势

    spring cloud微服务不定期会出现网络请求失败的错误.于是看了下后台日志,发现有几个请求会报如下的异常: Caused by: feign.RetryableException: Connec ...

  2. Jenkins git鬼畜集

    1. Jnekins服务重启后,莫名奇妙就报403错误,内网OK,把内网IP换成外网域名又可以. 莫名其妙解决:点了下notfiy后的Add,然后重输了一次密码,好了....但是这是新增一个账号啊!! ...

  3. Leetcode 之Simplify Path @ python

    Given an absolute path for a file (Unix-style), simplify it. For example,path = "/home/", ...

  4. 战争迷雾Fog Of War

    参考:https://forums.unrealengine.com/community/community-content-tools-and-tutorials/26436-tutorial-fo ...

  5. storm的代码实现

    先模拟产生一些数据 我把这些数据摘一部分下来 2017-06-10 18:25:56,092 [main] [org.apache.kafka.common.utils.AppInfoParser] ...

  6. 小朋友学Java(2):Win 7安装JDK

    1 打开命令行窗口,输入java -version. 若提示不认识java命令,说明没有java环境.   1.png 2 从甲骨文网站(http://www.oracle.com/technetwo ...

  7. Web of Science数据库中文献相关信息下载与保存

    1. Web of Science 数据库(https://apps.webofknowledge.com/): a. 所在网络必须由访问 该网站的权限. b.建议使用web of Science的核 ...

  8. Spring Boot: Cannot determine embedded database driver class for database type NONE

    配置启动项时提示如下: 原因是:springboot启动时会自动注入数据源和配置jpa 解决: 1 在@SpringBootApplication中排除其注入 @SpringBootApplicati ...

  9. 异常处理的设计与重构 pdf

    百度网盘: https://pan.baidu.com/s/1hsQIEGk

  10. IIS6.0 IIS7.5应用程序池自动停止的解决方法 搜集整理

    来源:http://www.guchengnet.com/1499.html IIS6.0 IIS7.5应用程序池自动停止的解决方法 搜集整理 发表于2016年12月14日 有2.3个月没有用本地的i ...