dijkstra最小花费

时间:2023-03-08 17:15:03
//Gang
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#define FOR(x,y,z) for(int x=y;x<=z;x++)
#define REP(x,y,z) for(int x=y;x>=z;x--)
#define INF 99999999
#define ll long long
using namespace std;
int n, m;
int x, y, z;
int a, b;
int u;
];
][];
];
int min1;
int main()
{
    scanf("%d %d", &n, &m);
    FOR(i, , m)
    {
        scanf("%d %d", &x, &y);
        scanf("%lf", &e[x][y]);
        e[x][y] = ( - e[x][y]) / ;
        e[y][x] = e[x][y];
    }
    scanf("%d %d", &a, &b);
    FOR(i, , n)
        dis[i] = e[a][i];
    dis[a] = ;
    book[a] = ;
    FOR(i, , n - )
{;
        FOR(j, , n)
        {
             && dis[j]>min)
            {
                min = dis[j];
                u = j;
            }
        }
        if (u == b)break;
    book[u] = ;
    FOR(v, , n)
        if (!book[v]&&dis[v]<dis[u] * e[u][v])
                dis[v] = dis[u] * e[u][v];
}
    printf( / dis[b]);
    ;
}
/*
3 3
1 2 1
2 3 2
1 3 3
1 3
*/