C++ || GCD || EASY TO UNDERSTAND || SHORT & SWEET CODE
\nclass Solution {\npublic:\n    long long countPairs(vector<int>& nums, int k) {\n        long long int ans = 0;\n        unordered_map<long long int,int> mp;\
````\nclass Solution {\npublic:\n    long long countPairs(vector<int>& nums, int k) {\n        long long int ans = 0;\n        unordered_map<long long int,int> mp;\n        for(auto &i: nums){\n            int g = __gcd(i,k);\n            for(auto &i: mp){\n                if((i.first*1LL*g)%k==0){\n                    ans += i.second;\n                }\n            }\n            mp[g]++;\n        }\n        return ans;\n    }\n};\n````
['Math', 'C', 'C++']