fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. // Speed
  4. #define fast_io ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
  5. // Typedefs
  6. #define int long long
  7. #define pb push_back
  8. #define ff first
  9. #define ss second
  10. #define all(x) (x).begin(), (x).end()
  11. #define rall(x) (x).rbegin(), (x).rend()
  12. #define sz(x) ((int)(x).size())
  13. #define endl '\n'
  14.  
  15. // Logic
  16. void solve() {
  17. int a, b;
  18. cin >> a >> b;
  19.  
  20. int ans = 0;
  21. for (int k = 1; k <= 60; ++k) {
  22. int cost_even = 0;
  23. int cost_odd = 0;
  24.  
  25. int current_size = 1;
  26. for (int i = 0; i < k; ++i) {
  27. if (i % 2 == 0) cost_even += current_size;
  28. else cost_odd += current_size;
  29.  
  30. if (cost_even > 2000000 && cost_odd > 2000000) break;
  31. current_size *= 2;
  32. }
  33.  
  34. bool possible1 = (cost_even <= a && cost_odd <= b);
  35.  
  36. bool possible2 = (cost_even <= b && cost_odd <= a);
  37.  
  38. if (possible1 || possible2) {
  39. ans = k;
  40. } else {
  41. break;
  42. }
  43. }
  44. cout << ans << endl;
  45. }
  46.  
  47. // Main
  48. int32_t main() {
  49. fast_io;
  50. int t;
  51. cin >> t;
  52. while (t--) {
  53. solve();
  54. }
  55. return 0;
  56. }
Success #stdin #stdout 0.01s 5296KB
stdin
7
1 1
1 2
3 1
4 3
5 2
1000000 1000000
1000000 1
stdout
1
2
2
2
3
20
2