All integer sequences given amount of integers and length of sequence
I don't have time to do a style review at the moment, so until I can expand on this later, I'll just suggest a different algorithm.



Rather than depending on string manipulation and generating more items than you need, just take an arithmetic approach.

In particular, you can take a deque of ints and add 1 to it until it is equal to the max value.

std::deque&lt; std::deque&lt;int&gt; &gt; results;
std::deque&lt;int&gt; min(Y, 1);
std::deque&lt;int&gt; max(Y, X);
for (; min != max; min = increment(min, Y)) {
    results.push_back(min);
}
results.push_back(max);


As a bit more explanation, a std::deque&lt;unsigned int&gt; is frequently used as a make-shift arbitrary precision integer. The way this is done is to have a sign flag, and then to see each element of the deque as part of a radix = std::numeric_limits&lt;unsigned int&gt;::max() number.

As a concrete example, a std::deque&lt;unsigned char&gt; d = {95, 14, 230} would represent 95 * 255^2 + 14 * 255^1 + 230 * 255^0 in the same way common base ten 134 = 1 * 10^2 + 3 * 10^2 + 4 * 10^0.

Anyway, I'm getting carried away with this. 

What you're in need of is a much more specific case of this. Rather than making a generic adder, all you have to do is just add 1, and if that causes the lowest digit to overflow, push it back down to a 1 and carry the add up the chain.

std::deque&lt;int&gt; increment(std::deque&lt;int&gt; d, int Y)
{
    bool carry = true;
    for (std::deque&lt;int&gt;::reverse_iterator it = d.rbegin(), end = d.rend(); it != end; ++it) {
        *it += 1;
        if (*it &gt; Y) {
            *it = 1;
        } else {
            carry = false;
        }
    }
    if (carry) {
        d.push_front(1);
    }
    return d;
}   


The above code is untested and unoptimized. It can probably be written more compactly, but it's been a long time since I've done anything like this, and I'm just trying to illustrate how it can be done arithmetically. 

Also, if you're concerned about performance, you might want to have increment mutate d rather than return a modified copy.