A recursive algorithm to find the number of distinct quantities of money from a pile of coins
Instead of calculating each combination recursively, you can build up the list one coinage type at a time.  This would involve fewer iterations in the case that any combinations form the same total, and more importantly wouldn't require adding up each combination separately.  For example:

std::set&lt;int&gt; sums;
for(int c = 0; c &lt; coins.size(); ++c)
{
    // Include zero on the initial list, but not subsequent ones
    if(sums.empty()) 
    {
        for(int q = 0; q &lt;= quantity[c]; ++q) 
        {
            sums.insert(q * coins[c]);
        }
    }
    else
    {
        std::vector&lt;int&gt; current(sums.begin(), sums.end());
        for(int q = 1; q &lt;= quantity[c]; ++q)
        {
            for(int sum : current) 
            {
                sums.insert(sum + q * coins[c]);
            }
        }
    }
}         


Using a vector instead of a set to accumulate sums (removing duplicates at the end) might be faster, and would eliminate the need for a temporary copy (current).  However, it wouldn't eliminate the redundant loops based off the same total, so some measurements would be needed to see which is better.

std::vector&lt;int&gt; sums;
for(int c = 0; c &lt; coins.size(); ++c)
{
    // Include zero on the initial list, but not subsequent ones
    if(sums.empty()) 
    {
        for(int q = 0; q &lt;= quantity[c]; ++q) 
        {
            sums.push_back(q * coins[c]);
        }
    }
    else
    {
        int oldSize = sums.size();
        for(int q = 1; q &lt;= quantity[c]; ++q)
        {
            for(int i = 0; i &lt; oldSize; ++i) 
            {
                sums.push_back(sums[i] + q * coins[c]);
            }
        }
    }
}  

std::sort(sums.begin(), sums.end());
sums.erase(std::unique(sums.begin(), sums.end()), sums.end());