2183. Count Array Pairs Divisible by K
IntuitionApproachComplexity
Time complexity:

Space complexity:
Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
typedef long long ll;

class Solution {
public:
    long long countPairs(vector<int>& nums, int k) {
        unordered_map<ll, ll> gcdMap;
        ll totalCount = 0;
        
        for (ll i = 0; i < nums.size(); ++i) {
            ll currentGCD = __gcd(nums[i], k);
            for (const auto &[gcdValue, occurrences] : gcdMap) {
                if ((currentGCD * gcdValue) % k == 0) {
                    totalCount += occurrences;
                }
            }
            gcdMap[currentGCD]++;
        }
        
        return totalCount;
    }
};
```
['C++']