2040. Kth Smallest Product of Two Sorted Arrays.cpp
Code\n\nclass Solution {\npublic:\n    long long kthSmallestProduct(vector<int>& nums1, vector<int>& nums2, long long k) {\n        \n        auto fn = [&](doub
**Code**\n```\nclass Solution {\npublic:\n    long long kthSmallestProduct(vector<int>& nums1, vector<int>& nums2, long long k) {\n        \n        auto fn = [&](double val) {\n            long long ans = 0; \n            for (auto& x : nums1) {\n                if (x < 0) ans += nums2.end() - lower_bound(nums2.begin(), nums2.end(), ceil(val/x)); \n                else if (x == 0) {\n                    if (0 <= val) ans += nums2.size(); \n                } else ans += upper_bound(nums2.begin(), nums2.end(), floor(val/x)) - nums2.begin(); \n            }\n            return ans; \n        }; \n        \n        long long lo = -pow(10ll, 10), hi = pow(10ll, 10)+1;\n        while (lo < hi) {\n            long long mid = lo + (hi - lo)/2; \n            if (fn(mid) < k) lo = mid + 1; \n            else hi = mid; \n        }\n        return lo; \n    }\n};\n```
['C']