2018ICPC南京D. Country Meow
题目:
题意:三维里有n个点,找一个最小的球将所有点覆盖。
题解:退火法模拟的一道板子题。

1 #include <stdio.h>
2 #include <iostream>
3 #include <math.h>
4 using namespace std;
5 const int MAXN=105;
6 const double EPS=1e-8;
7 struct Point{
8 double x,y,z;
9 Point(double _x=0,double _y=0,double _z=0){
10 x=_x;y=_y;z=_z;
11 }
12 };
13 Point Dots[MAXN];
14 int n;
15
16 double Distance(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 double Solve(){
20 double Step=100000,ans=1e9,mt;
21 Point z=Point(0.0,0.0,0.0);
22 int s=0;
23 while(Step>EPS){
24 for(int i=1;i<=n;++i){
25 if(Distance(z,Dots[s])<Distance(z,Dots[i])){
26 s=i;
27 }
28 }
29 mt=Distance(z,Dots[s]);
30 ans=min(ans,mt);
31 z.x+=(Dots[s].x-z.x)/mt*Step;
32 z.y+=(Dots[s].y-z.y)/mt*Step;
33 z.z+=(Dots[s].z-z.z)/mt*Step;
34 Step*=0.98;
35 }return ans;
36 }
37 int main(){
38
39 scanf("%d",&n);
40
41 for(int i=1;i<=n;++i){
42 double x,y,z;scanf("%lf%lf%lf",&x,&y,&z);
43 Dots[i]=Point(x,y,z);
44 }
45 printf("%.15f",Solve());
46
47 }
这题一开始没仔细看题只看了输出就被吓到了(还没学到立体几何)以为很难,后面没题可做了队友hcc发现就是一个最小球覆盖问题,然后我回忆起来前几天看到了这个板子就这套了一下就A了。
2018ICPC南京D. Country Meow的更多相关文章
- Gym101981D - 2018ACM-ICPC南京现场赛D题 Country Meow
2018ACM-ICPC南京现场赛D题-Country Meow Problem D. Country Meow Input file: standard input Output file: sta ...
- D.Country Meow 最小球覆盖 三分套三分套三分 && 模拟退火
// 2019.10.3 // 练习题:2018 ICPC 南京现场赛 D Country Meow 题目大意 给定空间内 N 个点,求某个点到 N 个点的距离最大值的最小值. 思路 非常裸的最小 ...
- 2018ICPC南京网络赛
2018ICPC南京网络赛 A. An Olympian Math Problem 题目描述:求\(\sum_{i=1}^{n} i\times i! \%n\) solution \[(n-1) \ ...
- Country Meow
Country Meow 和这基本一样 https://www.cnblogs.com/Fighting-sh/p/9809518.html #include<iostream> #inc ...
- Problem D. Country Meow 2018ICPC南京
n个点求出最小圆覆盖所有点 退火算法不会,不过这题可以用三分套三分写 x轴y轴z轴各三分 #include <cstdio> #include <cstring> #inclu ...
- [gym101981D][2018ICPC南京D题]Country Meow
题目链接 题目大意是求三维空间可以包含$n$个点的最小圆半径. 如果有做过洛谷P1337就会发现这到题很模拟退火,所以就瞎搞一发. $PS:$注意本题时限$3$秒. #include<bits/ ...
- 计蒜客 31001 - Magical Girl Haze - [最短路][2018ICPC南京网络预赛L题]
题目链接:https://nanti.jisuanke.com/t/31001 题意: 一带权有向图,有 n 个节点编号1~n,m条有向边,现在一人从节点 1 出发,他有最多 k 次机会施展魔法使得某 ...
- 计蒜客 30999 - Sum - [找规律+线性筛][2018ICPC南京网络预赛J题]
题目链接:https://nanti.jisuanke.com/t/30999 样例输入258 样例输出814 题意: squarefree数是指不含有完全平方数( 1 除外)因子的数, 现在一个数字 ...
- 计蒜客 30996 - Lpl and Energy-saving Lamps - [线段树][2018ICPC南京网络预赛G题]
题目链接:https://nanti.jisuanke.com/t/30996 During tea-drinking, princess, amongst other things, asked w ...
随机推荐
- 二、mycat基础知识、基本配置
官网 http://www.mycat.io/ Mycat 概要介绍 https://github.com/MyCATApache/Mycat-Server 入门指南 https://github.c ...
- TypeScript TSConfig All In One
TypeScript TSConfig All In One tsconfig.json https://www.typescriptlang.org/tsconfig https://www.typ ...
- PerformanceObserver API All In One
PerformanceObserver API All In One 性能监控 https://developer.mozilla.org/en-US/docs/Web/API/Performance ...
- learning all in one
learning learning all in one https://github.com/xgqfrms/learning/tree/gh-pages/GraphQL https://githu ...
- img & srcset
img & srcset 性能优化 <img class="fn tj s t u fa ai ht" width="3700" height=& ...
- BGV再掀DeFi投资热潮,NGK全球启动大会圆满落幕
此次全球启动大会的主题为"BGV再掀DeFi投资热潮,后市发展如何". 首先发言的是NGK灵石团队首席技术官STEPHEN先生,他先是对出席此次大会的嘉宾.到场的媒体记者以及NGK ...
- 「NGK每日快讯」12.17日NGK第44期官方快讯!
- Java基础篇(04):日期与时间API用法详解
本文源码:GitHub·点这里 || GitEE·点这里 一.时间和日期 在系统开发中,日期与时间作为重要的业务因素,起到十分关键的作用,例如同一个时间节点下的数据生成,基于时间范围的各种数据统计和分 ...
- 百度 Apollo无人车平台增加传感器
https://github.com/ApolloAuto/apollo/issues/1649 如果想加入一个新的传感器不是百度官方推荐的传感器到Apollo平台做法: First you can ...
- 微信小程序:优化接口代码-提取公共接口路径
方法一.将公共部分提取出来定义为baseURL变量 简化url,把里面公共部分提取出来.如https://api-hmugo-web.itheima.net/api/public/v1/categor ...