Greatest common divisor of 5 and 10 is 5, because both the numbers are divisible by 5. In order to find gcd of numbers, all factors of the numbers is needed to be determined and find the largest ...
// Approach: For each i, count pairs whose gcd is a multiple of i, then sweep downward subtracting // multiples to get exact-gcd counts; prefix sum them and binary search each query's rank.