一个词:迭代。地址:http://acm.pku.edu.cn/JudgeOnline/problem?id=2253
#include <stdio.h>
#include <math.h>

const double MAX = 20000.0;

typedef struct


{
double x;
double y;
}point;
point stone[201];

double map[201][201];

double dis ( point *a, point *b )


{

return sqrt ( (a->x-b->x)*(a->x-b->x) + (a->y-b->y)*(a->y-b->y) );
}

double maxest ( double a, double b )


{

return a > b ? a : b;
}

double cost[201];

double ford ( int s, int t, int n )


{

int u, v;

for ( u=0; u<n; u++ )

{
cost[u] = map[s][u];
}

int flag = 1;
while ( flag )

{
flag = 0;
for ( v=0; v<n; v++ )

{
for ( u=0; u<n; u++ )

{
if ( cost[u] < MAX )

{
double max = maxest ( cost[u], map[u][v] );
if ( cost[v] > max )

{
cost[v] = max;
flag = 1;
}
}
}
}
}
return cost[t];
}

int main ()


{

int n;
int i, j;
int count = 0;

while ( scanf ( "%d", &n ) != EOF && n )

{
for ( i=0; i<n; i++ )

{
scanf ( "%lf%lf", &stone[i].x, &stone[i].y );
}
for ( i=0; i<n; i++ )

{
for ( j=0; j<=i; j++ )

{
map[i][j] = map[j][i] = dis ( &stone[i], &stone[j] );
}
}
printf ( "Scenario #%d\nFrog Distance = %.3lf\n\n", ++count, ford ( 0, 1, n ) );
}
return 0;
}
