标签:des style blog http color java os io
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1217
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 4430 Accepted Submission(s): 2013
1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 #include <iostream> 5 #include <algorithm> 6 #include <map> 7 8 #define MAXX 35 9 #define INF 1000000000 10 double d[MAXX][MAXX]; 11 using namespace std; 12 13 void Flody(int n) 14 { 15 int i,j,k; 16 for(k=0; k<n; k++) 17 for(i=0; i<n; i++) 18 for(j=0; j<n; j++) 19 if(d[i][k] * d[k][j] > d[i][j]) 20 d[i][j] = d[i][k] * d[k][j]; 21 } 22 23 int main() 24 { 25 int n,i,j,t,tmp=0; 26 while(scanf("%d",&n)!=EOF&&n) 27 { 28 char str[105],str1[105],str2[105]; 29 int cas=0; 30 double rate; 31 map<string,int> m; 32 map<string,int>::iterator it; 33 for(i=0; i<n; i++) 34 for(j=0; j<n; j++) 35 d[i][j] = 0; 36 for(i=0; i<n; i++) 37 { 38 scanf("%s",str); 39 m[str]=cas++; 40 } 41 scanf("%d",&t); 42 for(i=0; i<t; i++) 43 { 44 scanf("%s%lf%s",str1,&rate,str2); 45 d[m[str1]][m[str2]]=rate; 46 } 47 Flody(n); 48 bool flag=false; 49 for(i=0; i<n; i++) 50 { 51 if(d[i][i]>1.0) 52 { 53 flag=true; 54 break; 55 } 56 } 57 if(flag) 58 { 59 printf("Case %d: Yes\n",++tmp); 60 } 61 else 62 { 63 printf("Case %d: No\n",++tmp); 64 } 65 } 66 return 0; 67 }
hdu 1217 (Floyd变形),布布扣,bubuko.com
标签:des style blog http color java os io
原文地址:http://www.cnblogs.com/ccccnzb/p/3893034.html