#P8207. Lowest Common Tree
Lowest Common Tree
Lowest Common Tree
Given two integers L and R, let V = {L, L+1, ..., R} be a set of positive integers. Construct a complete undirected graph G = (V,E) where the weight of an edge (u,v) is defined as the least common multiple (LCM) of u and v. In mathematical notation, the weight is given by:
\( \mathrm{lcm}(u,v)=\frac{u\times v}{\gcd(u,v)} \)
The Lowest Common Tree (LCT) of V is defined as the minimum spanning tree (MST) of the graph G. Your task is to compute the total weight of the LCT for the set V = {L, L+1, ..., R}.
Note: It is guaranteed that the input range is small enough to allow an O(n2) solution where n = R − L + 1.
inputFormat
The input consists of one line containing two space-separated integers L and R (L ≤ R), representing the range of vertices.
outputFormat
Output a single integer: the total weight of the lowest common tree (LCT) of the set V.
sample
2 3
6