Easy Approach Using GCD + HashMap
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```cpp []\nclass Solution {\npublic:\n    long long gcd_m(long long a, long long b) {\n        if (b == 0) \n            return a;\n        else\n            return gcd_m(b, a % b);\n    }\n    long long countPairs(vector<int>& nums, int k) {\n        ios::sync_with_stdio(false);\n        cin.tie(NULL);\n        cout.tie(NULL);\n        unordered_map<int, int> mp;\n        unordered_map<int, int> ::iterator it;\n        long long count = 0;\n\n        for (int i = 0; i < nums.size(); i++) {\n            long long find = gcd_m(nums[i], k);\n            it=mp.begin();\n            while(it!=mp.end()){\n                if ((find * it->first) % k == 0) {\n                    count += it->second;\n                }\n                it++;\n            }\n            mp[find]++;\n        }\n        return count;\n    }\n};\n\n```
['C++']