Python3 Easy to understand
```\nclass Solution:\n    def countPairs(self, nums: List[int], k: int) -> int:\n        dic = defaultdict(list)\n        for i, n in enumerate(nums):\n        
```\nclass Solution:\n    def countPairs(self, nums: List[int], k: int) -> int:\n        dic = defaultdict(list)\n        for i, n in enumerate(nums):\n            dic[n].append(i)\n        \n        res = 0\n        for v in dic.values():\n            if len(v) > 1:\n                res += len([ 1 for x, y in itertools.combinations(v, 2) if x * y % k == 0])\n        \n        return res\n
['Python3']