Advertisement
tungSfer

double

May 17th, 2021
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.80 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. #define ll long long
  4. #define el endl
  5. #define umi unordered_map<int, int>
  6. #define umll unordered_map<ll, ll>
  7. #define all(vect) vect.begin(), vect.end()
  8. #define reset(A) memset(A, 0, sizeof(A))
  9.  
  10. const int mod = 1e9 + 7;
  11.  
  12. using namespace std;
  13.  
  14. ll pow(int n)
  15. {
  16.     if(n == 1)
  17.         return 2;
  18.     if(n == 0)
  19.         return 1;
  20.     ll res = pow(n / 2);
  21.     res *= res;
  22.     if(n % 2 == 1)
  23.         res *= 2;
  24.     return res;
  25. }
  26.  
  27. void solve()
  28. {
  29.     ll n, k;
  30.     cin >> n >> k;
  31.     ll te = pow(n - 1);
  32.     if(k == te)
  33.     {
  34.         cout << n << el;
  35.         return;
  36.     }
  37.     while(te >= k)
  38.     {
  39.         if(te == k)
  40.         {
  41.             cout << (ll)log2(te) + 1 << el;
  42.             return;
  43.         }
  44.         te /= 2;
  45.     }
  46.    
  47.    
  48. }
  49. //1 2 1 3 121 4 1213121 5 121312141213121
  50. int main()
  51. {
  52.     int t = 1;
  53.     cin >> t;
  54. //  cin.ignore();
  55.     while(t--)
  56.     {
  57.         solve();
  58.     }
  59.     return 0;
  60. }
  61.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement