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 ...
随机推荐
- input和div模仿select,带输入提示
有时候我们需要select和input的结合体,即可以使用下拉框,同时也可以用来输入,输入的同时显示可选的下拉选项 先上html代码 <div class="input-group i ...
- wamp 的配置
一 . 安装 二 . 配置 安装过后打开E:\wamp2\wamp\bin\apache\Apache2.2.21\conf\httpd.conf 寻找Directoy 为文件路径 里面的默认文件删 ...
- 初识Pentaho(一)
学习一门语言或工具,首先得知道该工具的用途是什么.Pentaho 的官方定义是一个集数据集成和数据分析于一体的平台.这样的解释还是有点模糊.还是看其有哪些特点吧: ☐可以进行数据集成.谈到数据集成这 ...
- C++ STL lower_bound()和upper_bound()
lower_bound()和upper_bound()用法 1.在数组上的用法 假设a是一个递增数组,n是数组长度,则 lower_bound(a, a+n, x):返回数组a[0]~a[n-1]中, ...
- HTTP报文中的100状态码
HTTP状态码(status codes)是HTTP协议中,响应报文的起始行中包含的一种服务器用于向客户端说明操作状态的三位数字.例如在一个正常的GET请求完成后,服务器会向客户端返回 HTTP/ O ...
- 成都Uber优步司机奖励政策(2月28日)
滴快车单单2.5倍,注册地址:http://www.udache.com/ 如何注册Uber司机(全国版最新最详细注册流程)/月入2万/不用抢单:http://www.cnblogs.com/mfry ...
- 在Win10中通过命令行打开UWP应用
近期由于需要在WinX菜单中添加几个UWP应用,但发现很难找到相应的命令行,Universal Apps 的快捷方式属性里也没有. 于是到网上搜了很久才找到一个E文的页面,试了一下确实可行,分享给大家 ...
- libevent学习七(bufferevent)
1. 每个bufferevent 都拥有类型为struct evbuffer的input buffer和out buffer,分别供数据读取和数据写入使用. 2.读取和写入数据是通过编写和设置对应的回 ...
- 「专题训练」Hard problem(Codeforces Round #367 Div. 2 C)
题意与分析 题意:给出\(n\)个字符串,可以反转任意串,反转每个串都有其对应的花费\(c_i\).经过操作后是否能满足字符串\(\forall i \in [1,n] \text{且} i \in ...
- 「题目代码」P1060~P1065(Java)
P1060 谭浩强C语言(第三版)习题7.5 注意行末空格. import java.util.*; import java.io.*; import java.math.*; import java ...