Title Address
The main idea: Give the n kind of money, and M kind of money and money between the conversion value, to find out if there is a kind of money after conversion has become more
How to solve the problem: the shortest path to determine whether the last distance is greater than 1
#include <iostream> #include <cstdio> #include <cmath> #include <cstring> #include < algorithm> #include <queue> #include <string> #include <map> #include <stack> #include <
List> using namespace std;
const int MAXN = 30+10;
Double DIS[MAXN][MAXN];
void floyed (int n) {for (int k = 1, k <= N; k++) {for (int i = 1; I <= n; i++) { for (int j = 1; J <= N; j + +) {if (Dis[i][j] < dis[i][k]*dis[k][j]) d
IS[I][J] = Dis[i][k]*dis[k][j];
}}}} int main () {int n,m;
string S;
Map<string,int> MP;
int cas = 1;
while (scanf ("%d", &n)! = EOF) {if (!n) break;
memset (dis,0,sizeof (dis));
for (int i = 1; I <= n; i++) dis[i][i] = 1;
for (int i = 1; I <= n; i++) {cin>>s;
Mp[s] = i; } scanf ("%d",&M);
String s1,s2;
Double X;
for (int i = 0; i < m; i++) {cin>>s1>>x>>s2;
DIS[MP[S1]][MP[S2]] = x;
} floyed (n);
printf ("Case%d:", cas++);
int flag = 0;
for (int i = 1; I <= n; i++) {if (Dis[i][i] > 1.)
{cout<< "Yes" <<endl;
flag = 1;
Break
}} if (!flag) cout<< "No" <<endl;
} return 0;
}