原题链接:
https://vjudge.net/problem/POJ-2253
AC代码:
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <queue>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
double INF = 0x7fffffff;
void __init__()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
}
int main()
{
// __init__();
int n;
int cases = 0;
while (cin >> n && n)
{
cout << "Scenario #" << ++cases << endl;
int x[1005], y[1005];
for (int i = 0; i < n; i++)
cin >> x[i] >> y[i];
double dist[205][205];
for (int i = 0; i < n; i++)
{
for (int j = 0; j < i; j++)
{
dist[i][j] = sqrt(1.0*(x[i] - x[j]) * (x[i] - x[j]) + 1.0*(y[i] - y[j]) * (y[i] - y[j]));
dist[j][i] = dist[i][j];
}
dist[i][i] = 0;
}
for (int k = 0; k < n; k++)
{
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
dist[i][j] = min(dist[i][j], max(dist[i][k], dist[k][j]));
}
}
}
printf("Frog Distance = %.3lf\n\n", dist[0][1]);
}
}
如果G++提交WA的话可以试试C++提交