GCD concept
Code
# Code
```cpp []
#define li long long
class Solution {
public:
    long long countPairs(vector<int>& nums, int k) {
        li n = nums.size(), ans = 0;
        map<li, li> mpp;
        for (li i = 0; i < n; i++) {
            li r = __gcd(nums[i], k);
            for (auto i : mpp)
                if ((i.first * r) % k == 0)
                    ans += i.second;
            mpp[r]++;
        }
        return ans;
    }
};
```
['C++']