Binary search C++
Not very efficient. But could be accepted.\nUsing binary search.\n\nclass Solution {\npublic:\n    int sumOfFlooredPairs(vector<int>& nums) {\n        int n = n
Not very efficient. But could be accepted.\nUsing binary search.\n```\nclass Solution {\npublic:\n    int sumOfFlooredPairs(vector<int>& nums) {\n        int n = nums.size(), mod = 1e9 + 7;\n        sort(nums.begin(), nums.end());\n        \n        long long ret = 0;\n        for(int i = 0; i < n;) {\n            auto nit = upper_bound(nums.begin(), nums.end(), nums[i]);\n            long long cnt = (nit - nums.begin()) - i;\n            ret += cnt * (cnt - 1);\n            ret %= mod;\n            \n            int p = nums[i] + nums[i], index = (nit - nums.begin() - 1);\n            while(true) {\n                auto it = upper_bound(nums.begin(), nums.end(), p - 1);\n                if (it == nums.end()) {\n                    ret += (nums.size() - index) * (p / nums[i] - 1) * cnt;\n                    ret %= mod;\n                    break;\n                }\n                ret += ((it - nums.begin()) - index) * (p / nums[i] - 1) * cnt;\n                ret %= mod;\n                p += nums[i];\n                index = (it - nums.begin());\n            }\n            i += cnt;\n        }\n        return ret;\n    }\n};\n```
[]