Freddy Frog is sitting on a stone in the middle of a lake. Suddenly he notices Fiona Frog who is sitting on another stone. He plans to visit her, but since the water is dirty and full of tourists' sunscreen, he wants to avoid swimming and instead reach her by jumping.

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

The input will contain one or more test cases. The first line of each test case will contain the number of stones n (2<=n<=200). The next n lines each contain two integers xi,yi (0 <= xi,yi <= 1000) representing the coordinates of stone #i. Stone #1 is Freddy's stone, stone #2 is Fiona's stone, the other n-2 stones are unoccupied. There's a blank line following each test case. Input is terminated by a value of zero (0) for n.

Output

For each test case, print a line saying "Scenario #x" and a line saying "Frog Distance = y" where x is replaced by the test case number (they are numbered from 1) and y is replaced by the appropriate real number, printed to three decimals. Put a blank line after each test case, even after the last one.

Sample Input

2
0 0
3 4 3
17 4
19 4
18 5 0

Sample Output

Scenario #1
Frog Distance = 5.000 Scenario #2
Frog Distance = 1.414

题解:首先这道题不是让我们求最短路径,而是让我们去让我们找路径中最大值的最小值,并且n的范围是小于二百的,故可以用

floyed算法

接下来是代码:

提交的时候最好用G++,c++我的pow()函数好像

#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
double a[201][201];
int b[201][3];
int main()
{
int n,cnt=1;
while(~scanf("%d",&n)&&n)
{
for (int i=1;i<=n;i++)
scanf("%d %d",&b[i][1],&b[i][2]);
for (int i=1;i<=n-1;i++)
{
for (int j=i+1;j<=n;j++)
a[i][j]=a[j][i]=sqrt(pow((b[i][1]-b[j][1]),2)+pow((b[i][2]-b[j][2]),2));
}
for (int k=1;k<=n;k++)
for (int i=1;i<=n;i++)
for (int j=2;j<=n;j++)
{
if (a[i][j]>a[i][k]&&a[i][j]>a[k][j])
{
if (a[i][k]>a[k][j])
a[i][j]=a[j][i]=a[i][k];
else
a[i][j]=a[j][i]=a[k][j];
}
}
printf("Scenario #%d\n",cnt++);
printf("Frog Distance = %.3f\n",a[1][2]);
printf("\n");
}
}

D - Frogger的更多相关文章

  1. POJ 2253 Frogger(Dijkstra)

    传送门 Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 39453   Accepted: 12691 Des ...

  2. 2016HUAS_ACM暑假集训3B - Frogger

    好几天没更新博客了,因为这周在看关于图论的算法,有好几个(还是英文名字-_-||),人晕晕的...... 说一下这个Frogger吧.这个题目的话......难的不是做法,而是题意... 大致题意:有 ...

  3. Frogger(floyd变形)

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

  4. 最小瓶颈路 Uva 534 Frogger

    说明:关于Uva的题目,可以在vjudge上做的,不用到Uva(那个极其慢的)网站去做. 最小瓶颈路:找u到v的一条路径满足最大边权值尽量小 先求最小生成树,然后u到v的路径在树上是唯一的,答案就是这 ...

  5. POJ2253 Frogger

    Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 34865   Accepted: 11192 Descrip ...

  6. poj2253 最短路 floyd Frogger

    Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 28825   Accepted: 9359 Descript ...

  7. 最短路(Floyd_Warshall) POJ 2253 Frogger

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

  8. POJ 2253 Frogger

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

  9. poj 2253 Frogger dijkstra算法实现

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

  10. POJ 2253 Frogger (最短路)

    Frogger Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 28333   Accepted: 9208 Descript ...

随机推荐

  1. No bean class specified on bean definition 解决方案

    调试Spring项目出现No bean class specified on bean definition异常 但是控制台并没有给出其他相关信息了 这个时候可以在AbstractBeanDefini ...

  2. 标签控件JLabel的使用

    ---------------siwuxie095                             工程名:TestUI 包名:com.siwuxie095.ui 类名:TestLabel.j ...

  3. SQl Server 函数篇 聚合函数

    说一下数据库中的聚合函数 函数使用必须加小括号(), 5种聚合函数: 1.max最大值   select max(price) from car where code='c024'   --取这一列中 ...

  4. Configuration File (php.ini) Path Loaded Configuration File 都有加载php.ini文件,有什么不同的地方?

    Configuration File (php.ini) Path /usr/local/php7/etc      这个目录下面也有php.ini文件(如果在编译./configure -with- ...

  5. ann

    转自 http://blog.csdn.net/yiluoyan/article/details/45308785 这篇文章接着之前的车牌识别,从输入的车图片中分割识别出车牌之后,将进行下一步:车牌号 ...

  6. Linux如何修改网络环境参数

    如下设置: 检验是否可以连通,就使用ping命令ping 网关开始的时候总是现实unreachable 设置IP:sudo ifconfig eth0 133.133.133.190 netmask ...

  7. Amazon S3 云服务

    一.简介 Amazon Simple Storage Service (S3) 是一个公开的服务,Web 应用程序开发人员可以使用它存储数字资产,包括图片.视频.音乐和文档. S3 提供一个 REST ...

  8. 树莓派研究笔记(1)-- 安装Mono

    职业病啊,原谅我,第一步就是要安装Mono搞DOTNET 1. 更新系统 sudo apt-get update 2. 安装 Mono sudo apt-get install mono-comple ...

  9. java全栈day01-03注释、关键字与标识符

    通常我们需要在源代码中添加文字用来对进行代码解释说明,但这些文字并不是Java代码的语法,会导致编译出错.这时我们可以使用注释来完成这一事项! 在编译时,编译器会忽略注释的存在,就好像注释内容不存在一 ...

  10. C#知识点总结系列:3、C#中Delegate和Event

    一.Delegate委托可以理解为一个方法签名. 可以将方法作为另外一个方法的参数带入其中进行运算.在C#中我们有三种方式去创建委托,分别如下: public delegate void Print( ...