-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbits.cpp
66 lines (53 loc) · 1.12 KB
/
bits.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define fast_io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fr(i,a,b) for (int i =a;i<b;i++)
#define loop(x,n) for (int x = 0;x<n;++x)
#define mod 1000000007
#define inf (1LL<<60)
#define all(x) (x).begin(), (x).end()
using namespace std;
void precal(){
}
void solve (){
int n;
cin>>n;
vector<pair<ll,ll>> vec(n);
for (auto &[i,j]:vec){
cin>>i;
cin>>j;
}
for (int i =0;i<n;i++){
ll lowerval = vec[i].first;
ll topval = vec[i].second;
ll cur = lowerval;
while(cur<=topval){
ll mask = cur;
ll temp = ~mask;
temp = temp&(~(temp-1));
mask|=temp;
if(mask<=topval){
cur= mask;
}
else {
break;
}
}
cout<<cur<<"\n";
}
}
int main(){
fast_io;
cout<<fixed;
cout<< setprecision(10);
precal();
int t =1;
// cin>> t ;
for (int i =1;i<=t;i++){
// cout<< "Case #"<<i<<": ";
solve();
}
return 0;
}