simple brute force solution as the contrainsts are not big
\nint countPairs(vector<int>& nums, int k) {\n        int n=nums.size();\n        int cnt=0;\n        for(int i=0;i<n;i++){\n            for(int j=i+1;j<n;j++){
```\nint countPairs(vector<int>& nums, int k) {\n        int n=nums.size();\n        int cnt=0;\n        for(int i=0;i<n;i++){\n            for(int j=i+1;j<n;j++){\n                if(nums[i]==nums[j] && (i*j)%k==0){\n                    cnt++;\n                }\n            }\n        }\n        return cnt;\n    }\n};\n```
[]