MAP || GCD || FASTER THAN 80%
\nDO UPVOTE PLS ;))\n\n\nclass Solution {\npublic:\n    long long countPairs(vector<int>& nums, int k) {\n        unordered_map<int,int>m;\n        long long an
```\nDO UPVOTE PLS ;))\n\n\nclass Solution {\npublic:\n    long long countPairs(vector<int>& nums, int k) {\n        unordered_map<int,int>m;\n        long long ans=0;\n        for(int i=0;i<nums.size();i++)\n        {\n            int gcd=__gcd(nums[i],k);\n            int needed_num=k/gcd; // gcd(a,k) *gcd(b,k)%k==0 is same as a*b%k==0\n            for(auto x:m)\n            {\n                if(x.first%needed_num==0)\n                    ans+=x.second;\n            }\n            m[gcd]++;\n        }\n        return ans;\n    }\n};\n```
['C']