n个点求出最小圆覆盖所有点

退火算法不会,不过这题可以用三分套三分写

x轴y轴z轴各三分

 #include <cstdio>
#include <cstring>
#include <queue>
#include <cmath>
#include <algorithm>
#include <set>
#include <iostream>
#include <map>
#include <stack>
#include <string>
#include <vector>
#define pi acos(-1.0)
#define eps 1e-8
#define fi first
#define se second
#define rtl rt<<1
#define rtr rt<<1|1
#define bug printf("******\n")
#define mem(a,b) memset(a,b,sizeof(a))
#define name2str(x) #x
#define fuck(x) cout<<#x" = "<<x<<endl
#define f(a) a*a
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define sffff(a,b,c,d) scanf("%d %d %d %d", &a, &b, &c, &d)
#define pf printf
#define FRE(i,a,b) for(i = a; i <= b; i++)
#define FREE(i,a,b) for(i = a; i >= b; i--)
#define FRL(i,a,b) for(i = a; i < b; i++)+
#define FRLL(i,a,b) for(i = a; i > b; i--)
#define FIN freopen("data.txt","r",stdin)
#define gcd(a,b) __gcd(a,b)
#define lowbit(x) x&-x
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int mod = 1e9 + ;
const int maxn = 2e5 + ;
const int INF = 0x3f3f3f3f;
const LL INFLL = 0x3f3f3f3f3f3f3f3fLL;
int n;
struct node {
double p[];
} qu[maxn];
double cal ( node a ) {
double cnt = ;
for ( int i = ; i < n ; i++ )
cnt = max ( cnt, sqrt ( ( a.p[] - qu[i].p[] ) * ( a.p[] - qu[i].p[] ) + ( a.p[] - qu[i].p[] ) * ( a.p[] - qu[i].p[] ) + ( a.p[] - qu[i].p[] ) * ( a.p[] - qu[i].p[] ) ) );
return cnt;
}
node check ( int cnt, node now ) {
if ( cnt >= ) return now;
node ans1, ans2, ans, temp1, temp2;
double l = -, r = , ll, rr;
ans = temp1 = temp2 = now;
while ( eps < r - l ) {
ll = ( * l + r ) / , rr = ( * r + l ) / ;
temp1.p[cnt] = ll, temp2.p[cnt] = rr;
ans1 = check ( cnt + , temp1 );
ans2 = check ( cnt + , temp2 );
if ( cal ( ans1 ) > cal ( ans2 ) ) ans = ans1, l = ll;
else r = rr, ans = ans2;
}
return ans;
}
int main() {
while ( ~sf ( n ) ) {
for ( int i = ; i < n ; i++ ) scanf ( "%lf%lf%lf", &qu[i].p[], &qu[i].p[], &qu[i].p[] );
node ans;
printf ( "%lf\n", cal ( check ( , ans ) ) );
}
return ;
}

最新文章

  1. sql server中substring的用法
  2. Oracle 和 SqlServer 的区别
  3. HTML基础(四)——设置超链接的样式示例
  4. python下载网页源码 写入文本
  5. jquery之remove(),detach()方法详解
  6. 2014-3-11 星期二 晴 [卓有成效 master 摸索计划方案]
  7. 2015年百度之星初赛(1) --- C 序列变换
  8. (C/C++ )Interview in English - Virtual
  9. .net中三种数据类型转换区别((int),Int32.Parse() 和 Convert.toInt32() )
  10. HDU 3461 Code Lock(并查集,合并区间,思路太难想了啊)
  11. hdoj 4325 Flowers【线段树+离散化】
  12. PLSQL Package dubug方法
  13. SQL Server 已提交读快照 测试
  14. 算法分析-leedcode正则题目
  15. Orz 终于有了自己的博客地址
  16. Column store index 列数据如何匹配成行数据?
  17. 福州大学软件工程1916|W班 第2次作业成绩排名
  18. vue 使用技巧总结 19.01
  19. 201621123075 week06-接口、内部类
  20. Android在开发中的使用技巧之解决ScrollView嵌套RecyclerView出现的系列问题

热门文章

  1. elasticsearch备份与恢复
  2. Vue 项目在其他电脑 npm run dev 运行报错的解决方法
  3. sql批量更新
  4. JVM监控及堆栈内存
  5. python项目通过配置文件方式配置日志-logging
  6. 点滴拾遗 - 自定义 Format 控制 String.Format 行为
  7. 王者荣耀交流协会第一次scrum会议
  8. C#从一个窗体传递参数到另一个窗体的链接
  9. mininet实验 脚本实现控制交换机行为
  10. RAR和ZIP:压缩大战真相 (挺赞值得了解)