python3 13 lines
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```python3 []\nclass Solution:\n    def gcdValues(self, nums: List[int], queries: List[int]) -> List[int]:\n        maxv=max(nums)\n        co,lcount = [0]*(maxv+1), [0]*(maxv+1)\n        for v in nums: co[v]+=1\n        for i in range(1, maxv+1):\n            x = 0\n            for mul in range(i, maxv+1, i): x+=co[mul]\n            lcount[i]=x*(x-1)//2\n        for i in range(maxv, 0, -1):\n            for mul in range(2*i, maxv+1, i): lcount[i] -= lcount[mul]\n        acc=list(accumulate(lcount))\n        return [bisect.bisect_right(acc, q) for q in queries]\n```
['Python3']