题意:有两只青蛙和若干块石头,现在已知这些东西的坐标,两只青蛙A坐标和青蛙B坐标是第一个和第二个坐标,现在A青蛙想要到B青蛙那里去,并且A青蛙可以借助任意石头的跳跃,而从A到B有若干通路,问从A到B的所有通路上的最大边
链接:点我
floyd变形即可
1 #include<cstdio> 2 #include<iostream> 3 #include<algorithm> 4 #include<cstring> 5 #include<cmath> 6 #include<queue> 7 #include<map> 8 using namespace std; 9 #define MOD 1000000007 10 #define pb(a) push_back(a) 11 const int INF=0x3f3f3f3f; 12 const double eps=1e-5; 13 typedef long long ll; 14 #define cl(a) memset(a,0,sizeof(a)) 15 #define ts printf("***** "); 16 const int MAXN=210; 17 int n,m,tt,cnt; 18 struct Node 19 { 20 int x,y; 21 void in() 22 { 23 scanf("%d%d",&x,&y); 24 } 25 }node[MAXN]; 26 double dis(Node a,Node b) 27 { 28 return sqrt((double)(a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); 29 } 30 double dist[MAXN][MAXN]; 31 32 int main() 33 { 34 int i,j,k; 35 #ifndef ONLINE_JUDGE 36 freopen("1.in","r",stdin); 37 #endif 38 int ca=1; 39 while(scanf("%d",&n)!=EOF) 40 { 41 if(n==0) break; 42 for(i=0;i<n;i++) 43 { 44 node[i].in(); 45 } 46 cl(dist); 47 for(i=0;i<n;i++) 48 { 49 for(j=0;j<n;j++) 50 { 51 if(i==j) continue; 52 else dist[i][j]=dist[j][i]=dis(node[i],node[j]); 53 } 54 } 55 for(k=0;k<n;k++) 56 { 57 for(i=0;i<n;i++) 58 { 59 for(j=0;j<n;j++) 60 { 61 if(dist[i][j]>max(dist[i][k],dist[k][j])) dist[i][j]=max(dist[i][k],dist[k][j]); 62 } 63 } 64 } 65 printf("Scenario #%d Frog Distance = %.3lf ",ca++,dist[0][1]); 66 } 67 return 0; 68 }