题目传送门

 /*
最短路:Floyd算法模板题
*/
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
using namespace std; const int MAXN = + ;
const int INF = 0x3f3f3f3f;
double d[MAXN][MAXN];
int used[MAXN];
struct NODE
{
int x, y;
}node[MAXN]; double dis(int j, int i)
{
return sqrt ((node[j].x - node[i].x) * (node[j].x - node[i].x) + (node[j].y - node[i].y) * (node[j].y - node[i].y));
} void Floyd_Warshall(int n)
{
for (int k=; k<=n; ++k)
{
for (int i=; i<=n-; ++i)
{
for (int j=i+; j<=n; ++j)
{
if (d[i][k] < d[i][j] && d[k][j] < d[i][j])
{
if (d[i][k] < d[k][j])
d[i][j] = d[j][i] = d[k][j];
else
d[i][j] = d[j][i] = d[i][k];
}
}
}
} printf ("Frog Distance = %.3f\n", d[][]);
} int main(void) //POJ 2253 Frogger
{
//freopen ("D.in", "r", stdin); int n;
int cnt = ;
int first = ;
while (~scanf ("%d", &n) && n)
{
for (int i=; i<=n; ++i)
{
scanf ("%d%d", &node[i].x, &node[i].y);
}
for (int i=; i<=n-; ++i)
{
for (int j=i+; j<=n; ++j)
{
d[i][j] = d[j][i] = dis (i, j);
}
} printf ("Scenario #%d\n", ++cnt);
Floyd_Warshall (n);
puts ("");
} return ;
} /*
Scenario #1
Frog Distance = 5.000 Scenario #2
Frog Distance = 1.414
*/

最短路(Floyd_Warshall) POJ 2253 Frogger的更多相关文章

  1. [kuangbin带你飞]专题四 最短路练习 POJ 2253 Frogger

    求第一个点到第二个点的所有通路上最长的边 dijkstra的变形 每次松弛的是每条边通路上的的最长的边 WA了好几次是因为用了%lf 改成%f就过了…… /* ******************** ...

  2. POJ 2253 Frogger ,poj3660Cow Contest(判断绝对顺序)(最短路,floyed)

    POJ 2253 Frogger题目意思就是求所有路径中最大路径中的最小值. #include<iostream> #include<cstdio> #include<s ...

  3. POJ 2253 Frogger(dijkstra 最短路

    POJ 2253 Frogger Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fion ...

  4. POJ. 2253 Frogger (Dijkstra )

    POJ. 2253 Frogger (Dijkstra ) 题意分析 首先给出n个点的坐标,其中第一个点的坐标为青蛙1的坐标,第二个点的坐标为青蛙2的坐标.给出的n个点,两两双向互通,求出由1到2可行 ...

  5. poj 2253 Frogger (dijkstra最短路)

    题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

  6. poj 2253 Frogger (最长路中的最短路)

    链接:poj 2253 题意:给出青蛙A,B和若干石头的坐标,现青蛙A想到青蛙B那,A可通过随意石头到达B, 问从A到B多条路径中的最长边中的最短距离 分析:这题是最短路的变形,曾经求的是路径总长的最 ...

  7. POJ 2253 ——Frogger——————【最短路、Dijkstra、最长边最小化】

    Frogger Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Stat ...

  8. poj 2253 Frogger 最小瓶颈路(变形的最小生成树 prim算法解决(需要很好的理解prim))

    传送门: http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

  9. POJ 2253 Frogger

    题目链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissi ...

随机推荐

  1. unity3d 日志捕捉

    public class Test : MonoBehaviour { public string output = ""; public string stack = " ...

  2. [OpenJudge 3066]随机序列

    [OpenJudge 3066]随机序列 试题描述 Bob喜欢按照如下规则生成随机数: 第一步:令a[0] = S, 当n = 0: 第二步:a[n+1] = (a[n]*A+B)%P: 第三步:如果 ...

  3. C#装箱和拆箱(值类型和引用类型之间的转换)

    面向对象编程中,封箱指把非对象类型的数值或数据,包装成对象类型反之,拆箱指把对象类型拆成非对象的数值或数据. 例子:定义一个Circle 类 class Circle { double radius; ...

  4. 一起做RGB-D SLAM (1)

    前言 2016.11 更新 增加了对16.04的支持. 整理了过时的代码. SLAM,即Simultaneous Localization and Mapping,中文译作同时定位与地图创建,是近几十 ...

  5. move 和 CopyMemory的区别

    Move(ABuffer,P, Sizeof(ABuffer));   //指针传递            Move(ABuffer^,P^, Sizeof(TArrayByte));   //复制内 ...

  6. Linux命令之exit - 退出当前shell【返回值状态】

    原文链接:http://codingstandards.iteye.com/blog/836625   (转载请注明出处) 用途说明 exit命令用于退出当前shell,在shell脚本中可以终止当前 ...

  7. 完整java开发中JDBC连接数据库代码和步骤 JDBC连接数据库

    JDBC连接数据库 •创建一个以JDBC连接数据库的程序,包含7个步骤: 1.加载JDBC驱动程序: 在连接数据库之前,首先要加载想要连接的数据库的驱动到JVM(Java虚拟机), 这通过java.l ...

  8. 尖刀出鞘的display常用属性及css盒模型深入研究

    一:diplay:inline-block 含义:指元素创建了一个行级的块级元素,该元素内部(内容)被格式化成一个块级元素,同时元素本身则被格式化成一个行内元素.更简单的说就是说inline-bloc ...

  9. Swap Two Nodes in Linked List

    Given a linked list and two values v1 and v2. Swap the two nodes in the linked list with values v1 a ...

  10. MQTT——安装、测试

    MQTT学习笔记——MQTT协议体验 Mosquitto安装和使用         http://blog.csdn.net/xukai871105/article/details/39252653 ...