Advertisement
Guest User

Untitled

a guest
Jul 19th, 2017
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. const int L = 60, N = 1e5;
  5. typedef long long ll;
  6.  
  7. ll f[L];
  8. char s[N];
  9. int main(){
  10. f[0] = 1;
  11. for (int i = 1; i < L; ++ i)
  12. f[i] = f[i - 1] * 2LL;
  13. int n; cin >> n;
  14. for (int i = 0; i < n; ++ i)
  15. cin >> s[i];
  16. ll k; cin >> k;
  17. vector <int> ans;
  18. int cur_l = 0;
  19. while (k){
  20. while (k > f[n - cur_l - 1])
  21. k -= f[n - cur_l - 1], ++ cur_l;
  22. ans.push_back(cur_l), ++ cur_l, -- k;
  23. }
  24. for (auto i : ans) cout << s[i] << " ";
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement