Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const int L = 60, N = 1e5;
- typedef long long ll;
- ll f[L];
- char s[N];
- int main(){
- f[0] = 1;
- for (int i = 1; i < L; ++ i)
- f[i] = f[i - 1] * 2LL;
- int n; cin >> n;
- for (int i = 0; i < n; ++ i)
- cin >> s[i];
- ll k; cin >> k;
- vector <int> ans;
- int cur_l = 0;
- while (k){
- while (k > f[n - cur_l - 1])
- k -= f[n - cur_l - 1], ++ cur_l;
- ans.push_back(cur_l), ++ cur_l, -- k;
- }
- for (auto i : ans) cout << s[i] << " ";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement