Calculate permutation from Factorial representation of the K-th iteration of the N-th permutation
The loop

for(int i = 0; i &lt; N; i++)
    s.push_back(i);


is idiomatically expressed as std::iota(s.begin(), s.end(), 0) (you'd need to #include &lt;numeric&gt;).
A no naked loops principle demands giving a name to the

    for (int i = 0; i &lt; N; i++) {
        e.push_back(s[c[i]]);
        s.erase(s.begin() + c[i]);
    }


loop. It surely represents an important algorithm. What exactly does it do?

In any case, the s and e vectors shall not be exposed to the client.
Computing factorials restricts the utility of the code to N &lt; 21 (21! = 0x2_c507_7d36_b8c4_0000 doesn't fit in 64 bits). Unfortunately you cannot even express K within uint64_t limits for larger N. Consider BigInteger.
It is possible to avoid factorials (as well as ancillary vectors) by working other way around. Consider a pseudocode:

    while N &gt; 0:
        index = K % N
        swap a[N-1] with a[index]
        K /= N
        N -= 1


While correct, it doesn't produce the same K'th permutation as your code does. May I suggest changing it to produce the correct sequence as an exercise?


PS: a mandatory warning on using namespace std