LeetCode 952: Largest Component Size by Common Factor
Observation
I don't understand your solution.
Code Review
#define max(a, b) (a &gt; b ? a : b) // std::max(a, b)

Don't do this. Use std::max() directly.
Long gone are the days that we used macros to inline code like this. The std::max() will work correctly in all situation this macro has edge cased that will fail (especially if a or b are not just simple numbers).

The size_t is coming because you included a C header file cstdint. It is not guaranteed to be in the global namespace (it commonly is but its not guaranteed). So prefer to use std::size_t.
        const size_t max_nums = *std::max_element(nums.begin(), nums.end());