标签:des style blog http color java os io
http://acm.hdu.edu.cn/showproblem.php?pid=1596
Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6911 Accepted Submission(s): 2450
。/。/。/。/。/。/。/。/。/。/。/。/。/。/。/。/。/。/。/。/。/。/。/。/。/。/。/。
和上一篇差不多,小变形
1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <iostream> 5 #include <algorithm> 6 7 #define MAXX 1005 8 #define INF 1000000000 9 double d[MAXX][MAXX]; 10 11 int Floyd(int n) 12 { 13 int i,j,k; 14 for(k=0; k<n; k++) 15 for(i=0; i<n; i++) 16 for(j=0; j<n; j++) 17 if(d[i][k] * d[k][j] > d[i][j]) 18 d[i][j] = d[i][k] * d[k][j]; 19 } 20 21 int main() 22 { 23 int n,m,i,j; 24 //freopen("in.txt","r",stdin); 25 while(scanf("%d",&n)!=EOF) 26 { 27 double tmp; 28 memset(d,0,sizeof(d)); 29 30 for(i=0; i<n; i++) 31 { 32 for(j=0; j<n; j++) 33 { 34 scanf("%lf",&tmp); 35 d[i][j] = tmp; 36 } 37 } 38 Floyd(n); 39 scanf("%d",&m); 40 if(n == 0) 41 { 42 printf("0\n"); 43 continue; 44 } 45 int st,ed; 46 for(i=0; i<m; i++) 47 { 48 scanf("%d%d",&st,&ed); 49 if(d[st-1][ed-1] > 0) 50 { 51 printf("%.3lf\n",d[st-1][ed-1]); 52 } 53 else 54 { 55 printf("What a pity!\n"); 56 } 57 } 58 } 59 return 0; 60 }
hdu 1596(Floyd 变形),布布扣,bubuko.com
标签:des style blog http color java os io
原文地址:http://www.cnblogs.com/ccccnzb/p/3893117.html