0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-16 20:05:26 +00:00
Baoshuo Ren 2021-09-23 20:45:54 +08:00 committed by Baoshuo Ren
parent a1f6e8959c
commit 9617b48f6f
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

39
AcWing/1126/1126.cpp Normal file
View File

@ -0,0 +1,39 @@
#include <bits/stdc++.h>
using namespace std;
int n, m, x, y, a, b;
long double z, dist[2005], g[2005][2005];
bool st[2005];
void dijkstra() {
for (int i = 1; i <= n; i++) {
dist[i] = g[a][i];
}
dist[a] = 1;
st[a] = true;
for (int i = 1; i < n; i++) {
int t = -1;
for (int j = 1; j <= n; j++) {
if (!st[j] && (t == -1 || dist[t] < dist[j])) {
t = j;
}
}
st[t] = true;
for (int j = 1; j <= n; j++) {
dist[j] = max(dist[j], dist[t] * g[t][j]);
}
}
}
int main() {
cin >> n >> m;
for (int i = 1; i <= m; i++) {
cin >> x >> y >> z;
g[x][y] = g[y][x] = (100 - z) / 100.00;
}
cin >> a >> b;
dijkstra();
cout << fixed << setprecision(8) << 100 / dist[b] << endl;
return 0;
}