Advertisement
Semior001

lolololo

Dec 14th, 2016
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.36 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main(){
  6.     long long n, k, len, mid;
  7.     cin >> n >> k;
  8.     n = 1;
  9.     len = 2;
  10.     while (len <= k) {
  11.         len *= 2;
  12.         n++;
  13.     }
  14.     len--;
  15.     while (len > 0) {
  16.         mid = (len+1)/2;
  17.         if (k > mid) {
  18.             k = k - mid;
  19.         } else if (k == mid) {
  20.             cout << n << endl;
  21.             break;
  22.         }
  23.         n--;
  24.         len = mid - 1;
  25.     }
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement