Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 28802   Accepted: 9353

Description

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
这题可以用Dijkstra,将松弛条件改一下就可以了,改成
          if(dis[j]>max(dis[stone],map[stone][j])&&(vis[j]==0)){
dis[j]=max(dis[stone],map[stone][j]);
}
这样的结果就是求得能到达这点的路径上的最长边的最小值,求输出时要注意格式
 #include <iostream>
#include<math.h>
#include<limits.h>
#include<algorithm>
#include<iomanip>
using namespace std;
int num;
int vis[],stone[][];
int map[][],dis[];
int Dijkstra(){
for(int i=;i<num;i++){
dis[i]=INT_MAX;
vis[i]=;
}
dis[]=;
for(int i=;i<num;i++){
int min=INT_MAX;
int stone;
for(int j=;j<num;j++){
if((vis[j]==)&&min>dis[j]){
stone=j;
min=dis[j];
}
}
vis[stone]=;
if(min==INT_MAX)
break;
for(int j=;j<num;j++){
if(dis[j]>max(dis[stone],map[stone][j])&&(vis[j]==)){
dis[j]=max(dis[stone],map[stone][j]);
}
}
}
return dis[];
} int main() { cin>>num;
int count=;
while(num){
for(int i=;i<num;i++){
cin>>stone[i][]>>stone[i][];
}
for(int i=;i<num;i++){
for(int j=;j<num;j++){
map[i][j]=pow((stone[i][]-stone[j][]),)+pow((stone[i][]-stone[j][]),);
}
}
float fdis=sqrt(Dijkstra());
cout<<fixed;
cout<<"Scenario #"<<count<<endl<<"Frog Distance = "<<setprecision()<<fdis<<endl<<endl; count++;
cin>>num;
} return ;
}

最新文章

  1. .NET 的 WebSocket 开发包比较(转)
  2. 验证控件jQuery Validation Engine简单自定义正则表达式
  3. MySQL 第十天(视图、存储过程、函数、触发器)
  4. 写出易调试的SQL—西科软件
  5. XE7 Update 1 选 iOS 8.1 SDK 发布 iPhone 3GS 实机测试
  6. 在xcode运行编译时,编译成功,但项目中显示缺少该文件,这是只要关闭重启xcode即可。
  7. Groupon面经:Find paths in a binary tree summing to a target value
  8. Qt之等待提示框(QMovie)
  9. 浅谈OC运行时(RunTime)
  10. Hadoop源代码分析
  11. django之数据库orm
  12. CentOS 7安装nVIDIA显卡驱动程序
  13. .NET控件集ComponentOne 2018V3发布:新增图表动画及迷你图
  14. 【HQL】常用函数
  15. day 87-1 Vue学习七之vue-cookie
  16. 【WPF】两个下拉列表ComboBox的级联
  17. 设置WebApi里面命名空间参数
  18. Java 读取Excel2007 jar包冲突的问题(org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException)
  19. CentOS安装python setuptools and pip
  20. 栈与递归的实现(Hanoi塔问题等等)

热门文章

  1. 设置iframe高度自适应屏幕高度
  2. [BZOJ1179][APIO2009][强连通分量Tarjan+spfa]ATM
  3. NDK安装教程 not a valid ndk directory -- Eclipse
  4. Android AIDL实例解析
  5. ubuntu配置 测试环境 记录
  6. Vue计算属性和监听属性
  7. Git历险记(二)——Git的安装和配置
  8. 机器学习第3课:线性代数回顾(Linear Algebra Review)
  9. 为什么我获取不到这个css样式?js原生获取css样式总结
  10. JavaScript对象按值传递