C++ solution
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\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 {\n public:\n  int countSubMultisets(vector<int>& nums, int l, int r) {\n    constexpr int kMod = 1\'000\'000\'007;\n    // dp[i] := # of submultisets of nums with sum i\n    vector<long> dp(r + 1);\n    dp[0] = 1;\n    unordered_map<int, int> count;\n\n    for (const int num : nums)\n      ++count[num];\n\n    const int zeros = count[0];\n    count.erase(0);\n\n    for (const auto& [num, freq] : count) {\n      // stride[i] := dp[i] + dp[i - num] + dp[i - 2 * num] + ...\n      vector<long> stride = dp;\n      for (int i = num; i <= r; ++i)\n        stride[i] += stride[i - num];\n      for (int i = r; i > 0; --i)\n        if (i >= num * (freq + 1))\n          // dp[i] + dp[i - num] + dp[i - freq * num]\n          dp[i] = (stride[i] - stride[i - num * (freq + 1)]) % kMod;\n        else\n          dp[i] = stride[i] % kMod;\n    }\n\n    long ans = 0;\n    for (int i = l; i <= r; ++i)\n      ans = (ans + dp[i]) % kMod;\n    return ((zeros + 1) * ans) % kMod;\n  }\n};\n\n```
['C++']