Python , Count GCD
Calculate k/ gcd(n1,k) for each n1 in nums. If a n2 is diviable by k/ gcd(n1,k), then (n1,n2) is an available pair\nAnd since  k/ gcd(n1,k) may repeat, we can u
Calculate k/ gcd(n1,k) for each n1 in nums. If a n2 is diviable by k/ gcd(n1,k), then (n1,n2) is an available pair\nAnd since  k/ gcd(n1,k) may repeat, we can use counter to reduce complexity\n```\nclass Solution:\n    def countPairs(self, nums: List[int], k: int) -> int:\n        @functools.lru_cache(maxsize = None)\n        def gcd(a,b):\n            if a < b:\n                a,b = b,a\n            while a%b :\n                a,b = b, a%b\n            return b\n        g = [k//gcd(n,k) for n in nums]\n        cnt = collections.Counter(g)\n        # self-pairs should be excluded\n        self_pairs = sum(nums[i]%g[i] == 0 for i in range(len(nums)))\n        # avoid calculate twice for the same number\n        d = {}\n        pairs = 0\n        for i,n in enumerate(nums):\n            if n not in d:\n                d[n] = sum(cnt[c] for c in cnt if n%c == 0)\n            pairs+=d[n]\n        #each pairs appear twice, so the final result should divide by two\n        return (pairs -self_pairs )//2\n```
[]