-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bits
39 lines (33 loc) · 745 Bytes
/
Bits
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
#include <iostream>
#include <queue>
#include <stack>
#include <algorithm>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<cmath>
#include<bitset>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#define ordered_set tree <pair<int,int> ,null_type,less <pair<int,int> >, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
int main(){
int t;
cin >> t;
for (int i = 0; i < t; i++) {
long long l, r;
cin >> l >> r;
long long ans = l;
for (int j = 0; j < 63; j++) {
if ((ans | (1LL << j)) <= r)
ans |= (1LL << j);
//ans ^= (1LL << j);
if (ans > r)
break;
}
cout << ans << "\n";
}
}