nlogn solution
//the main part of the solution is to notice that for a fixed k, there are only so many value floor(n/k) can have\n    //so lets ask the question, for a denomin
//the main part of the solution is to notice that for a fixed k, there are only so many value floor(n/k) can have\n    //so lets ask the question, for a denominator aj how many indices exist such that floor(ai/aj)=some value q\n    //if we want to find some target value then we sum up number of indices that have value nums[i] in range [q*aj,q*(aj+1)-1]\n    //we also keep a frequency element freq[i] and multiply this result by freq[i] to avoid recalculation\n    //now does this satisfy the time complexity?, well time complexity is floor(n/1)+floor(n/2)...floor(n/n) which is approx. nlogn\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```\nclass Solution {\npublic:\n    //the main part of the solution is to notice that for a fixed k, there are only so many value floor(n/k) can have\n    //so lets ask the question, for a denominator aj how many indices exist such that floor(ai/aj)=some value q\n    //if we want to find some target value then we sum up number of indices that have value nums[i] in range [q*aj,q*(aj+1)-1]\n    //we also keep a frequency element freq[i] and multiply this result by freq[i] to avoid recalculation\n    //now does this satisfy the time complexity?, well time complexity is floor(n/1)+floor(n/2)...floor(n/n) which is approx. nlogn\n    long long llmin(long long i,long long j){\n        return i>j?j:i;\n    }\n    int sumOfFlooredPairs(vector<int>& nums) {\n        long long n=nums.size();\n        long long mod=1e9+7;\n        long long res=0;\n        vector<long long>freq(1e5+1);\n        vector<long long>p(1e5+1);\n        vector<long long>vals(1e5+1);\n        for(int i=0;i<n;++i){\n            freq[nums[i]]++;\n            p[nums[i]]++;\n        }\n        for(int i=1;i<=1e5;++i){\n            p[i]+=p[i-1];\n        }\n        for(long long i=1;i<=1e5;++i){\n            for(long long j=1;j*i<=1e5;++j){\n                vals[i]+=(p[llmin(100000,i*(j+1)-1)]-p[i*j-1])*j;\n            }\n            res=(res+vals[i]*freq[i])%mod;\n        }\n        return res;\n    }\n};\n```
['C++']