I don’t quite understand the solution to this problem, could anyone help?

What don’t you get about it?

I don’t have any idea how to solve it. Of course, I tried brute force by calculating all the GCDs and LCMs but got TLE obviously.

Try thinking about it from the perspective of individual prime factors.

For each number of the initial numbers of the ones after the LCM?

The ones after the LCM are defined in terms of the factors of the initial numbers.