#include <bits/stdc++.h>
typedef long long ll;
ll l,r,mid;
int t;
int main(){
scanf("%lld%lld",&l,&r);
if (l==r){
puts("1");
return 0;
}
for (int i=60;i>=0;i--)
if ((l&(1ll<<i))==(r&(1ll<<i)))
l-=(l&(1ll<<i)),r-=(r&(1ll<<i));
else {
mid=1ll<<i;
t=-1;
for (int j=i-1;j>=0;j--)
if (r&(1ll<<j)){
t=j;
break;
}
break;
}
ll l1=l,r1=(t==-1)?mid:mid+(1ll<<t+1)-1;
ll l2=mid|l,r2=2*mid-1;
if (l2<=r1) printf("%lld\n",r2-l1+1);
else printf("%lld\n",r1-l1+1+r2-l2+1);
}
相关文章
- 12-02A + B Problem
- 12-02洛谷 P1919 【模板】A*B Problem升级版 【快速傅里叶变换 FFT】
- 12-02B - Problem Arrangement ZOJ - 3777
- 12-02#333 Div2 Problem B Approximating a Constant Range(尺取法)
- 12-02BZOJ 2301: [HAOI2011]Problem b
- 12-02大数乘法(A * B Problem Plus)问题
- 12-02HDU 1002 A + B Problem II
- 12-02nyoj 623 A*B Problem II(矩阵)
- 12-02Codeup——605 | 问题 B: Problem E
- 12-02[luogu2522][bzoj2301][HAOI2011]Problem b