标签:
1 #include<cstdio> 2 #include<cstring> 3 #include<cmath> 4 using namespace std; 5 double s[1005][1005]; 6 int main() 7 { 8 int n,i,j,k; 9 while (~scanf("%d",&n)) 10 { 11 for (i=1;i<=n;i++) 12 for (j=1;j<=n;j++) scanf("%lf",&s[i][j]); 13 for (k=1;k<=n;k++)//如果这步放在j循环下面就会超时。 14 for (i=1;i<=n;i++) 15 for (j=1;j<=n;j++) 16 if (s[i][j]<s[i][k]*s[k][j]) s[i][j]=s[i][k]*s[k][j]; 17 scanf("%d",&n); 18 while (n--) 19 { 20 scanf("%d%d",&i,&j); 21 if (s[i][j]==0) printf("What a pity!\n"); 22 else printf("%0.3lf\n",s[i][j]); 23 } 24 } 25 }
hdu 1596 find the safest road (Floyd)
标签:
原文地址:http://www.cnblogs.com/pblr/p/4761031.html