POJ 2069 Super Star(计算几何の最小球包含+模拟退火)
Description
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
set is given in the following format.
n
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
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.
#include <cstdio>
#include <cmath> const int MAXN = 50;
const double EPS = 1e-6; struct Point3D {
double x, y, z;
Point3D(double xx = 0, double yy = 0, double zz = 0):
x(xx), y(yy), z(zz) {}
}; Point3D operator - (const Point3D &a, const Point3D &b) {
return Point3D(a.x - b.x, a.y - b.y, a.z - b.z);
} double dist(const Point3D &a, const Point3D &b) {
Point3D c = a - b;
return sqrt(c.x * c.x + c.y * c.y + c.z * c.z);
} Point3D p[MAXN];
int n; void solve() {
Point3D s;
double delta = 100, ans = 1e20;
while(delta > EPS) {
int d = 0;
for(int i = 1; i < n; ++i)
if(dist(s, p[i]) > dist(s,p[d])) d = i;
double maxd = dist(s, p[d]);
if(ans > maxd) ans = maxd;
s.x += (p[d].x - s.x)/maxd*delta;
s.y += (p[d].y - s.y)/maxd*delta;
s.z += (p[d].z - s.z)/maxd*delta;
delta *= 0.98;
}
printf("%.5f\n", ans);
} int main() {
while(scanf("%d", &n) != EOF && n) {
for(int i = 0; i < n; ++i) scanf("%lf%lf%lf", &p[i].x, &p[i].y, &p[i].z);
solve();
}
}
POJ 2069 Super Star(计算几何の最小球包含+模拟退火)的更多相关文章
- poj 2069 Super Star——模拟退火(收敛)
题目:http://poj.org/problem?id=2069 不是随机走,而是每次向最远的点逼近.而且也不是向该点逼近随意值,而是按那个比例:这样就总是接受,但答案还是要取min更新. 不知那个 ...
- poj 2069 Super Star —— 模拟退火
题目:http://poj.org/problem?id=2069 仍是随机地模拟退火,然而却WA了: 看看网上的题解,都是另一种做法——向距离最远的点靠近: 于是也改成那样,竟然真的A了...感觉这 ...
- POJ 2069 Super Star
模拟退火. #include<iostream> #include<cstdio> #include<cstring> #include<algorithm& ...
- poj 2069 Super Star 模拟退火
题目大意: 给定三位空间上的n(\(n \leq 30\))个点,求最小的球覆盖掉所有的点. 题解: 貌似我们可以用类似于二维平面中的随机增量法瞎搞一下 但是我不会怎么搞 所以我们模拟退火就好了啊QA ...
- 【POJ】2069.Super Star
题解 求一个最小的半径的球,包括三维平面上所有的点,输出半径 随机移动球心,半径即为距离最远的点,移动的方式是向离的最远的那个点移动一点,之后模拟退火就好 代码 #include <iostre ...
- Super Star(最小球覆盖)
Super Star http://poj.org/problem?id=2069 Time Limit: 1000MS Memory Limit: 65536K Total Submission ...
- POJ 2069 模拟退火算法
Super Star Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6422 Accepted: 1591 Spec ...
- 三分 POJ 2420 A Star not a Tree?
题目传送门 /* 题意:求费马点 三分:对x轴和y轴求极值,使到每个点的距离和最小 */ #include <cstdio> #include <algorithm> #inc ...
- POJ 2420 A Star not a Tree? (计算几何-费马点)
A Star not a Tree? Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 3435 Accepted: 172 ...
随机推荐
- 第一个electron
1 开发环境:node环境 2 下载electron:npm install electron --save-dev 3 package.json配置如下: { "name": & ...
- Tomcat问题之 启动 Cannot find /usr/local/tomcat/bin/setclasspath.sh
在linux启动startup命令报Cannot find /usr/local/tomcat/bin/setclasspath.sh 使用: unset CATALINA_HOME命令得以解决 ...
- 爬虫——Scrapy框架案例二:阳光问政平台
阳光热线问政平台 URL地址:http://wz.sun0769.com/index.php/question/questionType?type=4&page= 爬取字段:帖子的编号.投诉类 ...
- 转载自鸿燕藏锋-ETL讲解(很详细!!!)
ETL讲解(很详细!!!) ETL讲解(很详细!!!) ETL是将业务系统的数据经过抽取.清洗转换之后加载到数据仓库的过程,目的是将企业中的分散.零乱.标准不统一的数据整合到一起,为企业的决策提供 ...
- 『Python题库 - 简答题』 Python中的基本概念 (121道)
## 『Python题库 - 简答题』 Python中的基本概念 1. Python和Java.PHP.C.C#.C++等其他语言的对比? 2. 简述解释型和编译型编程语言? 3. 代码中要修改不可变 ...
- (杭电 1702)ACboy needs your help again!
ACboy needs your help again! Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Jav ...
- 数据结构中的hash
最近接触数据结构的时候突然发现一直在使用哈希表,哈希算法.那么到底什么是哈希(hash).查找资料发现一个比较有意思的解释,在此分享一下. 人家说的很好我就直接粘过来. =============== ...
- AtCoder Regular Contest 100 E - Or Plus Max
一道很好的dp题 dp[K]存的是 i满足二进制1属于K二进制1位置 最大的两个Ai 这样dp[K]统计的两个数肯定满足(i | j) <= K 然后不断做 update(dp[i | (1&l ...
- HTML5 tricks for mobile
iOS 7.1的Safari为meta标签新增minimal-ui属性,在网页加载时隐藏地址栏与导航栏 01. Creating a fullscreen experience On Android ...
- 环境变量Path简介
更多详细专业的详解,请参见:http://www.cnblogs.com/sunada2005/articles/2725277.html 什么是Path变量: PATH环境变量.作用是指定命令搜索路 ...