#include <bits/stdc++.h>
using namespace std;
int w[5][5], d[5], v[5];
int n = 3;
void dijkstra() {
    memset(d, 0x3f, sizeof d);
    memset(v, 0, sizeof v);
    d[1] = 0;
    for (int i = 1;i < n; i++) {
        int x = 0;
        for (int j = 1;j <= n; j++)
            if (!v[j] && (x == 0 || d[j] < d[x])) x = j;
        v[x] = 1;
        for (int y = 1;y <= n; y++)
            d[y] = min(d[y], d[x] + w[x][y]);
    }
}
int main() {
    int a, b; scanf("%d%d", &a, &b);
    memset(w, 0x3f, sizeof w);
    w[1][2] = a; w[2][3] = b;
    dijkstra();
    printf("%d\n", d[3]);
    return 0;
}

0 条评论

目前还没有评论...