###### hdu1217 floyd

1217 floyd算法 不过算的是相乘的最大值

#include <cstdio>
#include <iostream>
#include <map>
#include <string>
#include <cstring>

using namespace std;
const int C_MAX = 35;
double ex[C_MAX][C_MAX];//ex[u][v]表示u对v的汇率 u-->v
map<string, int> m;
int C,M;

bool floyd()
{
for(int k=1; k<=C; k++)
{
for(int i=1; i<=C; i++)
{
for(int j=1; j<=C; j++)
{
ex[i][j] = max(ex[i][j],ex[i][k] * ex[k][j]);
}
}
}

for (int i=1; i<=C; i++)
{
if(ex[i][i]>1)return true;

}
return false;
}

int main()
{
int Case = 1;
while((scanf("%d",&C)!=EOF)&&C){
for(int i=1;i<=C; i++){
for(int j=1; j<=C; j++){
if(i==j)ex[i][j] = 1;
else{ex[i][j] = -1.0;
}
}
}
string temp;
int fir, sec;
double exc;
for(int i=1; i<=C; i++)
{
cin >> temp;
m[temp] = i;
}
scanf("%d",&M);
for(int i=0; i<M; i++)
{
cin >> temp;
fir = m[temp];
scanf("%lf",&exc);
cin >> temp;
sec = m[temp];
ex[fir][sec] = exc;
}

if(floyd())printf("Case %d: Yes\n", Case);
else printf("Case %d: No\n",Case);
Case++;
}

return 0;
}



#### hdu1217（floyd)

2017-02-23 18:12:13

#### HDU1217 Floyd

2014-01-14 10:10:17

#### hdu1217 Arbitrage (Floyd)

2013-09-01 19:20:18

#### hdu1217（floyd算法）

2015-08-19 22:16:28

#### hdu1217 Arbitrage (floyd)

2016-02-06 13:15:04

#### hdu1217 Arbitrage（Floyd）

2017-09-11 18:59:34

#### HDU1217——Arbitrage(Floyd)

2016-03-26 12:38:14

#### Arbitrage hdu1217 Floyd算法

2013-01-30 19:52:14

#### HDU1217 Arbitrage Floyd算法

2014-12-12 14:08:59

#### HDU1217（floyd算法）

2012-08-01 17:21:11

hdu1217 floyd