Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- #define el endl
- #define umi unordered_map<int, int>
- #define umll unordered_map<ll, ll>
- #define all(vect) vect.begin(), vect.end()
- #define reset(A) memset(A, 0, sizeof(A))
- const int mod = 1e9 + 7;
- using namespace std;
- ll pow(int n)
- {
- if(n == 1)
- return 2;
- if(n == 0)
- return 1;
- ll res = pow(n / 2);
- res *= res;
- if(n % 2 == 1)
- res *= 2;
- return res;
- }
- void solve()
- {
- ll n, k;
- cin >> n >> k;
- ll te = pow(n - 1);
- if(k == te)
- {
- cout << n << el;
- return;
- }
- while(te >= k)
- {
- if(te == k)
- {
- cout << (ll)log2(te) + 1 << el;
- return;
- }
- te /= 2;
- }
- }
- //1 2 1 3 121 4 1213121 5 121312141213121
- int main()
- {
- int t = 1;
- cin >> t;
- // cin.ignore();
- while(t--)
- {
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement