Advertisement
Josif_tepe

Untitled

Sep 17th, 2023
586
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include <queue>
  2. #include <iostream>
  3. #include <vector>
  4. #include <cstring>
  5. #include <iostream>
  6. //#include <bits/stdc++.h>
  7. using namespace std;
  8. typedef long long ll;
  9. int main() {
  10.     ll n, k;
  11.     cin >> n >> k;
  12.    
  13.     string res = "";
  14.     while(n > 0) {
  15.         ll mid = (1LL << (n - 1));
  16.         if(k <= mid) {
  17.             res += "0";
  18.         }
  19.         else {
  20.             res += "1";
  21.             k = (1LL << n) - k + 1;
  22.         }
  23.         n--;
  24.     }
  25.     cout << res << endl;
  26.     return 0;
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement