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. C#WinForm如何调整控件的Tab按键顺序

    在日常生活中,很多用户都会有使用Tab键的习惯.而在C#的WinForm开发中,Tab按键的顺序默认是你拖拽进窗体的顺序.那么我们如何修改这个顺序呢?答案如下(以VS2010为例). 只需要点击[视图 ...

  2. 百度地图SDK v2.1.2使用方法

    1.开发工具 Android开发工具有很多,开发者可根据自己的喜好进行选择.在此,我们推荐开发者使用Eclipse作为自己的开发工具,本套开发指南也是针对Eclipse开发环境下进行编写的. 2.工程 ...

  3. vue插件开发与发布

    vue插件的规范 / plug.js Toast={}Toast.install=function(){ Vue.prototype.$toast=function(){ }} // 导出这个对象 e ...

  4. xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at:

    今天更新了一下mac系统,然后发现  idea的svn插件不能用了,有的报 有的报  is not under version 经查找需要做如下处理,打开终端,安装xcode: xcode-selec ...

  5. 100200F Think Positive

    传送门 题目大意 给你一个数n和长度为n的序列,序列中的每个数均为1或-1,如果一个点j对于任意的k都满足题目中给的式子,则j是一个合法位置,问这样的j有多少个 分析 这道题有两种方法,分别对应代码1 ...

  6. 100211D Police Cities

    传送门 分析 看到这个题我们的第一反应自然是Tarjan缩点,在这之后我们可以发现实际只要在缩点之后所有出度或入度为0的点布置警察局就可以达到要求,我们用dpij表示考虑前i个出度或入度为0的点共布置 ...

  7. bootstrap学习网址

    http://www.bootcss.com/  bootstrap中文学习网址

  8. WordCountPro 编码与测试

    WordCountPro github项目地址:https://github.com/handsomesnail/WordCountPro PSP表格 PSP2.1  PSP阶段  预估耗时(小时) ...

  9. python连接数据库--查询数据

    #!/usr/bin/python # -*- coding: utf-8 -*- import pymysql def fileDB(): # 打开数据库连接(ip/数据库用户名/登录密码/数据库名 ...

  10. javascript 文本框值变化触发事件

    javascript 文本框值变化触发事件jo.find(".price").bind('input onpropertychange', function () { me.cal ...