1862. Sum of Floored Pairs.cpp
Code\n\nclass Solution {\npublic:\n    int sumOfFlooredPairs(vector<int>& nums) {\n        int m = *max_element(nums.begin(), nums.end()); \n        vector<long
**Code**\n```\nclass Solution {\npublic:\n    int sumOfFlooredPairs(vector<int>& nums) {\n        int m = *max_element(nums.begin(), nums.end()); \n        vector<long> vals(m+1); \n        for (auto x : nums) \n            ++vals[x];         \n        for (int x = m; x > 0; --x) \n            for (int xx = 2*x; xx <= m; xx += x) \n                vals[xx] += vals[x];         \n        for (int i = 1; i < vals.size(); ++i) \n            vals[i] += vals[i-1];         \n        int ans = 0; \n        for (auto x : nums) \n            ans = (ans + vals[x]) % 1\'000\'000\'007; \n        return ans; \n    }\n};\n```
['C']