C++ Solution Beats 75%
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    vector<int> gcdValues(vector<int>& nums, vector<long long>& queries) {\n        int maxi = *max_element(nums.begin(), nums.end());\n        vector<long long> gcdcount(maxi + 1, 0);\n        \n        // Count divisors for each number in nums\n        for(auto child : nums) {\n            for(int i = 1; i * i <= child; i++) {\n                if(child % i == 0) {\n                    gcdcount[i]++;\n                    if(i != child / i) {\n                        gcdcount[child / i]++;\n                    }\n                }\n            }\n        }\n\n        for(int i = 1; i <= maxi; i++) {\n            long long value = gcdcount[i];\n            gcdcount[i] = (value * (value - 1)) / 2;\n        }\n\n        for(int i = maxi; i >= 1; i--) {\n            for(int j = i * 2; j <= maxi; j += i) {\n                gcdcount[i] -= gcdcount[j];\n            }\n        }\n\n        for(int i = 1; i <= maxi; i++) {\n            gcdcount[i] += gcdcount[i - 1];\n        }\n\n        vector<int> ans;\n        for(int i = 0; i < queries.size(); i++) {\n            long long ind = queries[i]+1;\n            int myind = lower_bound(gcdcount.begin(), gcdcount.end(), ind) - gcdcount.begin();\n            ans.push_back(myind);\n        }\n\n        return ans;\n    }\n};\n\n```
['C++']