链接:https://ac.nowcoder.com/acm/contest/332/G
题意:
求a|(a+1)|(a+2)|...|(b-1)|b。
思路:
求a-b的差的每一个二进制位
自己也看不懂。。。
代码:
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
int main()
{
LL a,b;
while(cin >> a >> b)
{
LL res = a;
LL x = 1;
while (a + x <= b)
{
res |= (x + a);
x <<= 1;
}
cout << (res|b) << endl;
}
return 0;
}