中文 binary search
\nclass Solution\n{\npublic:\n    long long kthSmallestProduct(vector<int> &nums1, vector<int> &nums2, long long k)\n    {\n        // \u4E58\u79EF\u503C\u4E00\
```\nclass Solution\n{\npublic:\n    long long kthSmallestProduct(vector<int> &nums1, vector<int> &nums2, long long k)\n    {\n        // \u4E58\u79EF\u503C\u4E00\u5B9A\u5728 [-10000000000, 10000000000]\u4E4B\u95F4.\n        // \u503C\u7684\u6700\u5927\u8303\u56F4\u8DE8\u5EA6(MAX-VLAUE-RANGE) = 20000000000\n\n        // \u7B97\u6CD5\u590D\u6742\u5EA6\u8003\u8651: Log(MAX-VLAUE-RANGE) * |nums1| * log(|nums2|)\n        // \u56E0\u6B64, \u5C06nums1\u8BBE\u5B9A\u4E3A\u957F\u5EA6\u8F83\u5C0F\u7684\u6570\u7EC4\n        if (nums1.size() > nums2.size())\n        {\n            nums1.swap(nums2);\n        }\n\n        long long begin = -10000000000ll;\n        long long end = 10000000000ll;\n        long long result = -1;\n        while (begin <= end)\n        {\n            auto middle = (begin + end) / 2;\n\n            //\u4E0D\u5927\u4E8Emiddle\u7684\u4E58\u79EF\u5BF9\u7684\u4E2A\u6570\n            long long count = 0;\n            for (auto &n1 : nums1)\n            {\n                count += getTotalNotGreaterThan(nums2, n1, middle);\n            }\n            if (count >= k)\n            {\n                result = middle;\n                end = middle - 1;\n            }\n            else\n            {\n                begin = middle + 1;\n            }\n        }\n        return result;\n    }\n\n    //\u5728nums2\u4E2D, \u4E0En1\u76F8\u4E58\uFF0C\u4F46\u662F\u4E58\u79EF\u503C\u4E0D\u5927\u4E8Evalue\u7684\u5143\u7D20\u4E2A\u6570.\n    long long getTotalNotGreaterThan(vector<int> &nums2, long long n1, long long value)\n    {\n        //\u53EF\u4EE5\u81EA\u5DF1\u5199\u4E00\u4E2Abinary search, \u6211\u8FD9\u91CC\u5957\u7528stl upper_bound/lower_bound\u65B9\u6CD5.\n        if (n1 >= 0)\n        {\n            return distance(nums2.begin(), upper_bound(nums2.begin(), nums2.end(), -1, [=](int v1, int v2)\n                                                       { return value < (long)v2 * n1; }));\n        }\n        else\n        {\n            n1 *= -1;\n            return distance(lower_bound(nums2.begin(), nums2.end(), -1, [=](int v1, int v2)\n                                        { return (long)v1 * n1 < -value; }),\n                            nums2.end());\n        }\n    }\n};\n```
[]