以最先不同的为开始,往后都可以取到1
#include <bits/stdc++.h> typedef long long ll; using namespace std; // inline ll read() { // ll x = 0, y=1; // char c = getchar(); // while (c=='-') { // y = -y; // c = getchar(); // } // while (c>='0'&&c<='9') { // x = x*10+(c-'0'); // c = getchar(); // } // return x; // } inline ll read() { ll f = 1, x = 0; char c = getchar(); while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar(); } while(c >= '0' && c <= '9') { x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return f * x; } int main() { ll T = read(); while (T--) { ll l = read(), r=read(), ans=0; bool flag = false; int i; for (i=63;i>=0;i--) { if ((l>>i&1)!=(r>>i&1)) { break; } } printf("%lld\n", (1ll<<(i+1))-1); } return 0; }