Frogger(floyd变形)
Time Limit:1000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u
Description
Unfortunately Fiona's stone is out of his jump range. Therefore Freddy considers to use other stones as intermediate stops and reach her by a sequence of several small jumps.
To execute a given sequence of jumps, a frog's jump range obviously must be at least as long as the longest jump occuring in the sequence.
The frog distance (humans also call it minimax distance) between two stones therefore is defined as the minimum necessary jump range over all possible paths between the two stones.
You are given the coordinates of Freddy's stone, Fiona's stone and all other stones in the lake. Your job is to compute the frog distance between Freddy's and Fiona's stone.
Input
Output
The frog distance (humans also call it minimax distance) between two stones therefore is defined as the minimum necessary jump range over all possible paths between the two stones.
#include <iostream>
#include <algorithm>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath> using namespace std; const int sz = ;
const double inf = 10.0e8;
double d[sz][sz], x[sz], y[sz];
int n; void get_dist(int i, int j)
{
d[i][j] = d[j][i] = sqrt((x[i] - x[j]) * (x[i] - x[j]) +
(y[i] - y[j]) * (y[i] - y[j]));
} void floyd()
{
for(int k = ; k <= n; k++){
for(int i = ; i <= n; i++){
for(int j = ; j <= n; j++){
d[i][j] = min(d[i][j], max(d[i][k], d[k][j]));
}
}
}
} int main()
{
int ca = ;
while(scanf("%d", &n) && n){
for(int i = ; i <= n; i++){
for(int j = ; j <= n; j++){
d[i][j] = inf;
}
d[i][i] = 0.0;
}
for(int i = ; i <= n; i++){
scanf("%lf %lf", x + i, y + i);
for(int j = i - ; j > ; j--){
get_dist(i, j);
}
}
floyd();
printf("Scenario #%d\nFrog Distance = %.3lf\n\n", ca++, d[][]);
}
return ;
}
Frogger(floyd变形)的更多相关文章
- POJ2253——Frogger(Floyd变形)
Frogger DescriptionFreddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fi ...
- UVA10048 Audiophobia[Floyd变形]
UVA - 10048 Audiophobia Consider yourself lucky! Consider yourself lucky to be still breathing and h ...
- poj 2253 Frogger(floyd变形)
题目链接:http://poj.org/problem?id=1797 题意:给出两只青蛙的坐标A.B,和其他的n-2个坐标,任一两个坐标点间都是双向连通的.显然从A到B存在至少一条的通路,每一条通路 ...
- hdu 1596(Floyd 变形)
http://acm.hdu.edu.cn/showproblem.php?pid=1596 find the safest road Time Limit: 10000/5000 MS (Java/ ...
- hdu 1217 (Floyd变形)
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1217 Arbitrage Time Limit: 2000/1000 MS (Java/Others) ...
- poj2253 Frogger(Floyd)
题目链接 http://poj.org/problem?id=2253 题意 给出青蛙A,B和若干石头的坐标,现在青蛙A要跳到青蛙B所在的石头上,求出所有路径中最远那一跳的最小值. 思路 Floyd算 ...
- POJ 2253 Frogger Floyd
原题链接:http://poj.org/problem?id=2253 Frogger Time Limit: 1000MS Memory Limit: 65536K Total Submissi ...
- UVa 10048 (Floyd变形) Audiophobia
题意: 给一个带权无向图,和一些询问,每次询问两个点之间最大权的最小路径. 分析: 紫书上的题解是错误的,应该是把原算法中的加号变成max即可.但推理过程还是类似的,如果理解了Floyd算法的话,这个 ...
- find the mincost route(floyd变形 无向图最小环)
Time Limit: 1000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission( ...
随机推荐
- JS 数字转换为大写金额
function DX(n) { if (!/^(0|[1-9]\d*)(\.\d+)?$/.test(n)) return "数据非法"; var unit = "千百 ...
- atitit.解决struts2 SpringObjectFactory.getClassInstance NullPointerException
atitit.解决struts2 SpringObjectFactory.getClassInstance NullPointerException #--现象 java.lang.NullPoint ...
- android开源项目和框架
特效: http://www.androidviews.net/ http://www.theultimateandroidlibrary.com/ 常用效果: 1. https://github.c ...
- 改善C#公共程序类库质量的10种方法
最近重构一套代码,运用以下几种方法,供参考. 1 公共方法尽可能的使用缓存 public static List<string> GetRegisteredCompany() { Str ...
- asp.net MVC的EF与easyui DataGrid数据绑定
页面代码 @{ Layout = null; } <!DOCTYPE html> <html> <head> <meta name="viewpor ...
- iOS-OC-APP热更新,动态更新(仿QQ打开或关闭某个功能)
一.前言 iOS开发更新APP我觉得是比较坑的就是审核时间比较长,审核比较严,对于刚入行的小伙伴来说,雷区比较多:所以热更新是比较重要的: 大家也许会发现我们常用的QQ现在下来也就一百多兆,但是用了几 ...
- C#:如何解决WebBrowser.DocumentCompleted事件的多次调用
关于DocumentCompleted事件,MSDN给出的解释是在文档加载完毕后执行,但是在我的程序中DocumentCompleted却被多次调用,查了一下资料,大概出现了以下几种情况. 1.Web ...
- SoapUI Pro Project Solution Collection-DataSource(jdbc,excel)
here give a solution for excel file change the excel configuration these: Set Excel file path in cur ...
- IOS图像拉伸解决方案
UIButton实现背景拉伸,即图片两端不拉伸中间拉伸的办法有如下两种: 第一种方法很简单而且使用性更广.做法就是直接拉伸想要setBackgroundImage的image,代码如下: UIImag ...
- sublime3 配置node build环境
折腾了很久,原来如此简单 1.package control 安装nodejs 2.修改Nodejs.sublime-settings文件,将nodejs路径修改成自己的 3.sublime tex ...