8 if (n<=0 || k<=0 || k>n)
return;
10 iota(d.begin(), d.end(), 1);
13 for (
int i=0; i<k; i++) aperm.push_back(d[i]);
14 perms.push_back(aperm);
15 reverse(d.begin()+k, d.end());
16 }
while (next_permutation(d.begin(), d.end()));
17 if (valbegin!=1 || increment!=1){
for (
auto& p:perms){
for (
auto& pp:p) pp = increment*(pp-1)+valbegin; } }
22 iota(d.begin(), d.end(), 1);
27 for (
auto& perm:perms) sort(perm.begin(), perm.end());
28 for (
auto ip=perms.begin(); ip!=perms.end(); ip++){
29 for (
auto jp=perms.rbegin(); (jp.base()-1)!=ip; jp++){
30 if (*(ip)==*(jp)) perms.erase(jp.base()-1);
34 if (valbegin!=1 || increment!=1){
for (
auto& p:perms){
for (
auto& pp:p) pp = increment*(pp-1)+valbegin; } }