Easy solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    long long countPairs(vector<int>& nums, int k) {\n        int n = nums.size();\n        long long count = 0;\n        unordered_map<int,int> p;\n        vector<int> v;\n        for(int i=1;i*i <= k;i++){\n           if(k%i == 0) v.push_back(i);\n           if((k/i)!= i and k%i==0) v.push_back(k/i);\n        }\n        for(int i=0;i<n;i++){\n            count += (p[k/(__gcd(nums[i],k))]);\n            for(auto j:v){\n                if(nums[i]%j == 0) p[j]++;\n            }\n        }\n        return count;\n    }\n};\n```
['C++']