题意:阅读题....无限大的奶酪里有n个球形的洞。你的任务是帮助老鼠A用最短时间到达老鼠O的位置。奶酪里面的移动速度为10S一个单位,但是在洞里可以瞬间移动,求最短时间

思路:先耐心看题目...然后就floyd随便做了

#include<bits/stdc++.h>
using namespace std;
const int maxn = 505;
int x[maxn],y[maxn],z[maxn],r[maxn];
double d[maxn][maxn];int main()
{int n,cas=1;while (scanf("%d",&n)!=EOF && n!=-1){for (int i = 1;i<=n+2;i++){if (i<=n)scanf("%d%d%d%d",&x[i],&y[i],&z[i],&r[i]);elsescanf("%d%d%d",&x[i],&y[i],&z[i]),r[i]=0;}n+=2;for (int i = 1;i<=n;i++)for (int j = 1;j<=n;j++){if (i==j)d[i][j]=0;else{double dist = sqrt((double)(x[i]-x[j])*(x[i]-x[j])+(double)(y[i]-y[j])*(y[i]-y[j])+(double)(z[i]-z[j])*(z[i]-z[j]));if (dist<=r[i]+r[j])d[i][j]=0;elsed[i][j]=dist-(r[i]+r[j]);}}for (int k = 1;k<=n;k++)for (int i = 1;i<=n;i++)for (int j =1;j<=n;j++)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);printf("Cheese %d: Travel time = %.0lf sec\n",cas++,d[n-1][n]*10);}
}

Once upon a time, in a giant piece of cheese, there lived a cheese mite named Amelia Cheese Mite.
Amelia should have been truly happy because she was surrounded by more delicious cheese than she
could ever eat. Nevertheless, she felt that something was missing from her life.
One morning, her dreams about cheese were interrupted by a noise she had never heard before. But
she immediately realized what it was - the sound of a male cheese mite, gnawing in the same piece of
cheese! (Determining the gender of a cheese mite just by the sound of its gnawing is by no means easy,
but all cheese mites can do it. That’s because their parents could.)
Nothing could stop Amelia now. She had to meet that other mite as soon as possible. Therefore
she had to find the fastest way to get to the other mite. Amelia can gnaw through one millimeter of
cheese in ten seconds. But it turns out that the direct way to the other mite might not be the fastest
one. The cheese that Amelia lives in is full of holes. These holes, which are bubbles of air trapped
in the cheese, are spherical for the most part. But occasionally these spherical holes overlap, creating
compound holes of all kinds of shapes. Passing through a hole in the cheese takes Amelia essentially
zero time, since she can fly from one end to the other instantly. So it might be useful to travel through
holes to get to the other mite quickly.
For this problem, you have to write a program that, given the locations of both mites and the holes
in the cheese, determines the minimal time it takes Amelia to reach the other mite. For the purposes of
this problem, you can assume that the cheese is infinitely large. This is because the cheese is so large
that it never pays for Amelia to leave the cheese to reach the other mite (especially since cheese-mite
eaters might eat her). You can also assume that the other mite is eagerly anticipating Amelia’s arrival
and will not move while Amelia is underway.
Input
The input file contains descriptions of several cheese mite test cases. Each test case starts with a line
containing a single integer n (0 ≤ n ≤ 100), the number of holes in the cheese. This is followed by
n lines containing four integers xi
, yi
, zi
, ri each. These describe the centers (xi
, yi
, zi) and radii ri
(ri > 0) of the holes. All values here (and in the following) are given in millimeters.
The description concludes with two lines containing three integers each. The first line contains the
values xA, yA, zA, giving Amelia’s position in the cheese, the second line containing xO, yO, zO, gives
the position of the other mite.
The input file is terminated by a line containing the number ‘-1’.
Output
For each test case, print one line of output, following the format of the sample output. First print the
number of the test case (starting with 1). Then print the minimum time in seconds it takes Amelia
to reach the other mite, rounded to the closest integer. The input will be such that the rounding is
unambiguous.

Sample Input
1
20 20 20 1
0 0 0
0 0 10
1
5 0 0 4
0 0 0
10 0 0
-1
Sample Output
Cheese 1: Travel time = 100 sec
Cheese 2: Travel time = 20 sec

UVA 1001 Say Cheese(最短路)相关推荐

  1. UVA 1001 Say Cheese 奶酪里的老鼠(最短路,floyd)

    题意:一只母老鼠想要找到她的公老鼠玩具(cqww?),而玩具就丢在一个广阔的3维空间(其实可以想象成平面)上某个点,而母老鼠在另一个点,她可以直接走到达玩具的位置,但是耗时是所走过的欧几里得距离*10 ...

  2. UVA 1376 Animal Run 最短路

    平面图最小割转最短路 书上是说以边为结点建图 但是我觉得好像以每块空白区域为结点建图会更自然点.把矩形的右上方编号为0,左下方编号为1,分别为起点终点 //#pragma comment(linker ...

  3. UVa 816 (BFS求最短路)

    /*816 - Abbott's Revenge ---代码完全参考刘汝佳算法入门经典 ---strchr() 用来查找某字符在字符串中首次出现的位置,其原型为:char * strchr (cons ...

  4. uva 1001 奶酪里的老鼠(狄杰斯特拉或弗洛伊德)

     题意:在一个三维的奶酪里面有n(n<=100)个洞,老鼠A想到达老鼠B的位置, 在洞里面可以瞬间移动,在洞外面的移动速度为10秒一个单位,求最短时间 本来不难的一道题,因为图论做得少所以不 ...

  5. uva 10801 - Lift Hopping(最短路Dijkstra)

    1 /* 2 题目大意: 3 就是一幢大厦中有0-99的楼层, 然后有1-5个电梯!每个电梯有一定的上升或下降速度和楼层的停止的位置! 4 问从第0层楼到第k层最少经过多长时间到达! 5 6 思路:明 ...

  6. UVA 11367 Full Tank? 最短路

    以状态(u,fuel)为结点建图(把每个点拆成100个),表示在点u时还剩下fuel个单位的燃料,那么状态就可以这样转移: (u,fuel)->(u,fuel+i)  : 加i单位的燃料,所以这 ...

  7. Uva 10537过路费 反向最短路

    题意 运送货物需要缴纳过路费,进入一个村庄需要缴纳1个单位的货物,而进入一个城镇时,每20个单位的货物中就要上缴1个单位(向上取整).你的任务时已知运送到终点的货物数量,求出初始时所需要的最少货物,以 ...

  8. 为什么《剑桥中国史》系列没有魏晋南北朝史和两宋史?

    根据剑桥大学出版社网站,<剑桥中国史>系列中: 第2卷 <剑桥中国魏晋南北朝史>尚未出版 第5卷 <剑桥中国五代宋朝史上>英文版已经出版,中文版尚未出版 第6卷 & ...

  9. 紫书《算法竞赛入门经典》

    紫书<算法竞赛入门经典>题目一览 第3章 数组和字符串(例题) UVA 272 TEX Quotes UVA 10082 WERTYU UVA 401 Palindromes UVA 34 ...

最新文章

  1. 1282. Game Tree
  2. Java多线程之线程池的使用示例
  3. [推荐].NET开发人员必备的10个Visual Studio Add-Ins
  4. android开发 权限大全
  5. Simple DNS Plus 5.2 build 117
  6. 互联网架构阶段 数据库读写分离 Amoeba
  7. tensorflow Image 解码函数
  8. 经典排序算法(十六)--珠排序Bead Sort
  9. hfss matlab api 天线,应用HFSS-MATLAB-API设计圆极化微带天线
  10. cad计算机制图如何标注,零件序号和图号有什么区别,CAD制图中怎样标注零件序号...
  11. 渗透测试的种类(黑白盒)、脆弱性评估、OWASP Top 10、PTES-渗透测试执行标准
  12. 阿里巴巴面经、面试流程、面试题
  13. tekla钢结构算量_钢结构、Tekla及建筑工业化厂商对Tekla软件的开发和应用
  14. 根号2以及π的计算--关于无理数的畅想
  15. DNK基础之静态库、动态库、编译流程
  16. Mstar的Monitor方案笔记(七)——EDID基本数据结构
  17. Excel文件减肥修复终极办法----解决Excel文件打开慢的问题
  18. 泛泰A850工程机与正式机分区表对比
  19. win10 文件夹设置区分大小写
  20. Python学习之旅-15

热门文章

  1. 单边指数信号的特点_单边带通信的特点
  2. ASP.NET图书管理系统简单实现步骤
  3. Android 8.1 从零开始写 HAL -- (2) 实现 HAL 主体
  4. Choco求解器的安装
  5. 怎么找到一抛物线数组的顶点_抛物线与顶点坐标的关系如何确定抛物线开口是向上还是向下?知道抛物线的定点坐标,和x轴的交点或y轴的交点,怎么求抛物线的解析式?抛物线的顶点坐标与抛物线还有什么关系?...
  6. Netstat命令使用方法
  7. 计算机编程英语单词多少,计算机编程常用英语单词
  8. 串行口数据缓冲寄存器 SBUF 之 初步了解
  9. unexpected char: '\' @ line 3, column 133. s\react-native-gestu
  10. [ZZ]AppiumForWindows 菜鸟计划合集