题目: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 用 XML 自定义边框(只上下边框有色)

    直接上代码: <?xml version="1.0" encoding="UTF-8"?> <layer-list xmlns:android ...

  2. C语言 linux环境基于socket的简易即时通信程序

    转载请注明出处:http://www.cnblogs.com/kevince/p/3891033.html      ——By Kevince 最近在看linux网络编程相关,现学现卖,就写了一个简易 ...

  3. Linux-storage-stack-diagram

    just a diagram 一目了然. 对于isci 只是用过LIO和STGT 两种后端. 这里有各种后端的比较. http://scst.sourceforge.net/comparison.ht ...

  4. 茴香豆的第五种写法---设置ExpandableListView系统自带图标按下效果

    1 编写groupindicator_selector.xml如下: <?xml version="1.0" encoding="utf-8"?> ...

  5. UNIX网络编程卷1 时间获取程序server UDP 协议无关

    本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlie /** * UDP 协议无关 调用 getaddrinfo 和 udp_server **/ ...

  6. 用ADB(Android Debug Bridge)实时监测Android程序的运行

      监控Android设备上程序的运行,需要ADB的配合,具体ADB工具的介绍以及命令选项可见博客: http://blog.csdn.net/mliubing2532/article/details ...

  7. hahahahah

    dsfsefesfsffsfsfsfsfesfsfsfsfsfsfspackage realm;   import java.util.ArrayList; import java.util.List ...

  8. ASP.NET页面上传文件时提示文件大小超过请求解决方法

    在webconfig中节点 <system.web> </system.web> 下加入以下代码:maxRequestLength为限制上传文件大小,executionTime ...

  9. BootStrap 模态框禁用空白处点击关闭问题

    模态框为信息编辑窗口,涉及好多内容,填了半天,若一不小心点了空白处,那就前功尽弃了..... 所以我们很有必要禁用鼠标点击空白处模态框关闭的功能. $('#myModal').modal({backd ...

  10. ##DAY9 UITabBarController

    ##DAY9 UITabBarController UIViewController的tabBarController UIViewController的tabBarItem #pragma mark ...