Time complexity:-Max(n,m)
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```cpp []\nclass Solution {\npublic:\n    using ll=long long;\n    vector<int> gcdValues(vector<int>& nums, vector<long long>& queries) {\n        int m=*max_element(nums.begin(),nums.end());\n        vector<long long> a(m+1),b(m+1);\n        for(int&x:nums) a[x]++;\n        for(int i=1;i<=m;i++){\n            for(int j=i;j<=m;j+=i){\n                b[i]+=a[j];\n            }\n            b[i]=b[i]*(b[i]-1)/2;\n        }\n        for(int i=m;i>0;i--){\n            for(int j=2*i;j<=m;j+=i){\n                b[i]-=b[j];\n            }\n        }\n        vector<int>  ans;\n        for(int i=1;i<=m;i++) b[i]+=b[i-1];\n        for(ll&q:queries){\n            ans.push_back(upper_bound(b.begin(),b.end(),q)-b.begin());\n        }\n        return ans;\n    }\n};\n```
['C++']