C++ Code
class Solution {\npublic:\n    long long countPairs(vector& nums, int k) {\n        std::ios_base::sync_with_stdio(false);\n        std::cout.tie(nullptr);\n   
class Solution {\npublic:\n    long long countPairs(vector<int>& nums, int k) {\n        std::ios_base::sync_with_stdio(false);\n        std::cout.tie(nullptr);\n        std::cin.tie(nullptr);\n        unordered_map<int,int> mpp;\n        long long ans=0;\n        for(auto i:nums){\n            int get=__gcd(k,i);\n            int need=k/get;\n            for(auto j:mpp){\n                if(j.first%need==0){\n                    ans+=j.second;\n                }\n            }\n            mpp[get]++;\n        }\n        return ans;\n    }\n};\n
['C++']