题目描述
blablabla
样例
blablabla
算法1
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
blablabla
算法2
(暴力枚举) $O(n^2)$
blablabla
时间复杂度
参考文献
C++ 代码
#include<iostream>
#include<cstring>
using namespace std;
const int N = 2010;
double g[N][N];
double dist[N];
bool st[N];
int n, m, a, b;
void dijkstra(int a)
{
dist[a] = 1;
for (int i = 1; i <= n; i ++)
{
int t = -1;
for(int j = 1; j <= n; j ++)
{
if (!st[j] && (t == -1 || dist[j] > dist[t]))
t = j;
}
st[t] = true;
for (int j = 1; j <= n; j ++)
if (dist[j] < dist[t] * g[t][j])
dist[j] = dist[t] * g[t][j];
}
}
int main()
{
cin >> n >> m;
while(m --)
{
int a, b, c;
cin >> a >> b >> c;
double z = (100.0 - c) / 100;
g[a][b] = g[b][a] = max(g[a][b], z);
}
cin >> a >> b;
dijkstra(a);
printf("%.8f", 100 / dist[b]);
return 0;
}