EASY AND FAST!!
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>& v, vector<long long>& q){\n        int n = v.size();\n        int maxx = *max_element(v.begin(), v.end());\n        vector<int> cntDivisors(maxx + 1, 0);\n        for(auto x : v){\n            for(int i = 1; i * i <= x; i++){\n                if(x % i == 0){\n                    cntDivisors[i]++;\n                    if(i != x / i){\n                        cntDivisors[x / i]++;\n                    }\n                }\n            }\n        }\n        vector<long long int> gcdCount(maxx + 1, 0);\n        for(int g = maxx; g >= 1; g--){\n            long long int count = cntDivisors[g];\n            gcdCount[g] = 1ll * count *(count - 1) / 2;\n            for(int mult = 2 * g; mult <= maxx; mult += g){\n                gcdCount[g] -= gcdCount[mult];\n            }\n        }\n        \n        vector<long long int> pref(maxx + 1, 0);\n        for(int g = 1; g <= maxx; g++){\n            pref[g] = pref[g - 1] + gcdCount[g];\n        }\n        vector<int> ans;\n        for(auto q : q){\n            long long int left = 1, right = maxx, answer = -1;\n            while(left <= right){\n                long long int mid =(left + right) / 2;\n                if(pref[mid] > q){\n                    answer = mid;\n                    right = mid - 1;\n                } else{\n                    left = mid + 1;\n                }\n            }\n            ans.push_back(answer);\n        }\n\n        return ans;\n    }\n};\n```
['C++']