C++ | 10 line code
\nclass Solution {\npublic:\n    long long countPairs(vector<int>& nums, int k) {\n        unordered_map<int,long long> mp;\n        long long ans=0;\n        f
```\nclass Solution {\npublic:\n    long long countPairs(vector<int>& nums, int k) {\n        unordered_map<int,long long> mp;\n        long long ans=0;\n        for(auto n:nums){\n            int gcd=__gcd(n,k);\n            int req=k/gcd;\n            for(auto it:mp)\n                if(it.first%req==0)\n                    ans+=it.second;\n            mp[gcd]++;\n        }\n        return ans;\n    }\n};\n```
['C', 'C++']