floyd变形,求最短路径最大值
#include<cstdio>
#include<cstdlib>
#include<math.h>
#include<algorithm>
using namespace std;
struct point{
double x,y;
}p[205];
double g[250][250];
const double INF=100000000.0;
int n;
double dis(point p1,point p2){
return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y));
}
int main(){
int kase=0;
while(scanf("%d",&n)==1&&n){
for(int i=1; i<=n; i++)
scanf("%lf %lf",&p[i].x,&p[i].y);
for(int i=1; i<=n; i++)
for(int j=1; j<=n; j++)
g[i][j]=(i==j?0:INF);
for(int i=1; i<=n; i++)
for(int j=i+1; j<=n; j++){
g[i][j]=g[j][i]=dis(p[i],p[j]);
}
for(int k=1; k<=n; k++)
for(int i=1; i<=n; i++)
for(int j=1; j<=n; j++){
g[i][j]=min(g[i][j],max(g[i][k],g[k][j]));
}
printf("Scenario #%d\n",++kase);
printf("Frog Distance = %.3lf\n\n",g[1][2]);
}
return 0;
}