#include<bits/stdc++.h>
#include "perm.h"
using namespace std;
vector<int> construct_permutation(long long k)
{
vector<int>a;
int cnt=__lg(k),sm=cnt;
k-=1ll<<cnt;
while(k>0)
{
int x=__lg(k);
a.push_back(x);
k-=1ll<<x;
++sm;
}
vector<int>res;
int lb=0;
for(int i=0;i<cnt;++i)
{
if(!a.empty()&&a.back()==i)
res.push_back(lb++),a.pop_back();
res.push_back(--sm);
}
reverse(res.begin(),res.end());
return res;
}剪贴板
剪贴板 zwjqib7x
剪贴板信息
剪贴板信息
- 收录
- 更新