题目:click here

题意:

  给出两只青蛙的坐标A、B,和其他的n-2个坐标,任意两坐标间是双向连通的。显然从A到B存在至少一条的通路,每一条通路的元素都是这条通路中前后两个点的距离,这些距离中又有一个最大距离。现在要求求出所有通路的最大距离,并把这些最大距离作比较,把最小的一个最大距离作为青蛙的最小跳远距离。

分析:

  最小化最大值--------

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#define power(a) ((a)*(a))
using namespace std;
const int INF = 1e9+;
const int M = ; struct node { double x, y; } point[M]; // 点的坐标
int n, tcase;
double cost[M][M]; // 邻接矩阵存图
double dis( node a, node b ) { // 距离
return sqrt( power(a.x-b.x) + power(a.y-b.y) );
} void floyd() { // 弗洛伊德算法
for( int k=; k<=n; k++ )
for( int i=; i<=n; i++ )
for( int j=; j<=n; j++ )
cost[i][j] = min( cost[i][j], max(cost[i][k],cost[k][j]) );
} void solve() {
for( int i=; i<=n; i++ )
scanf("%lf%lf", &point[i].x, &point[i].y );
for( int i=; i<=n; i++ ) {
cost[i][i] = ;
for( int j=i+; j<=n; j++ ) {
double d = dis( point[i], point[j] );
cost[i][j] = d; // 建立无向图
cost[j][i] = d;
}
}
floyd();
printf("Scenario #%d\n", tcase++);
printf("Frog Distance = %.3f\n\n", cost[][] );
}
int main() {
tcase = ;
while( ~scanf("%d", &n ) && n ) {
solve();
}
return ;
}

POJ 2253 Frogger floyd算法的更多相关文章

  1. POJ 2253 Frogger Floyd

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

  2. poj 2253 Frogger dijkstra算法实现

    点击打开链接 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 21653   Accepted: 7042 D ...

  3. 最短路(Floyd_Warshall) POJ 2253 Frogger

    题目传送门 /* 最短路:Floyd算法模板题 */ #include <cstdio> #include <iostream> #include <algorithm& ...

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

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

  5. POJ. 2253 Frogger (Dijkstra )

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

  6. POJ 2253 Frogger(dijkstra 最短路

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

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

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

  8. POJ 2253 Frogger

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

  9. POJ 2253 Frogger(Dijkstra变形——最短路径最大权值)

    题目链接: http://poj.org/problem?id=2253 Description Freddy Frog is sitting on a stone in the middle of ...

随机推荐

  1. android 设置头像以及裁剪功能

    在android的开发过程中,经常遇到设置用户头像以及裁剪图像大小的功能.昨天我遇到了设置用户头像的功能,开始不知道怎么搞,在技术群里问也没人回 答,就研究了微信用户设置头像的功能,了解到用户设置图像 ...

  2. python-操作hive

    python访问hive2 HiveServer2为客户端在远程执行hive查询提供了接口,通过Thrift RPC来实现,还提供了多用户并发和认证功能.目前使用python的用户可以通过pyhs2这 ...

  3. asp.net MVC Razor 语法(1)

    Razor 不是编程语言.它是服务器端标记语言. 什么是 Razor ? Razor 是一种允许您向网页中嵌入基于服务器的代码(Visual Basic 和 C#)的标记语法. 当网页被写入浏览器时, ...

  4. SQL Server索引进阶:第十三级,插入,更新,删除

    在第十级到十二级中,我们看了索引的内部结构,以及改变结构造成的影响.在本文中,继续查看Insert,update,delete和merge造成的影响.首先,我们单独看一下这四个命令. 插入INSERT ...

  5. ASP.NET listBbox控件用法

    ListBox基本功能使用方法 2011-06-09 13:23:16|  分类: .NET/C# |  标签:listbox基本功能使用方法   |举报 |字号大中小 订阅     ListBox基 ...

  6. JS动态创建table

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  7. 微信支付 v 3.3.6

    文字说明: 前提:注册.申请服务号,开通微信支付. 涉及到的参数:AppId.AppSecret.原始ID(自动回复).mch_id(商户号).Key(商户密钥:自己设定.) 统一规范: 要求 认证方 ...

  8. RPC介绍以及编程

    1 RPC介绍 RPC(Remote Procedure Call Protocol)——远程过程调用协议,它是一种通过网络从远程计算机程序上请求服务,而不需要了解底层网络技术的协 议. RPC采用客 ...

  9. UITextField键盘类型

    UITextField *text = [[UITextField alloc]initWithFrame:CGRectMake(20, 20, 130, 30)];  //初始化textfield并 ...

  10. VC MFC 屏蔽ESC和ENTER键关闭对话框

    方法一: 窗体头文件中加入: protected: virtual BOOL PreTranslateMessage(MSG* pMsg); // PreTranslateMessage是消息在送给T ...