位运算/CodeForces 485c Bits

 1 /*
 2     PROBLEM:CF 485C
 3     AUTHER:Nicole
 4     MEMO:位运算 二进制
 5 */
 6 #include<cstdio>
 7 int main()
 8 {
 9     int n;
10     scanf("%d",&n);
11     for (int i=1;i<=n;i++)
12     {
13         long long l,r;
14         scanf("%lld%lld",&l,&r);
15         long long x=1;
16         while (l<=r)
17         {
18             long long temp=l|x;
19             if (temp>r) break;
20             l=temp;
21             x=x<<1;
22         }
23         printf("%lld\n",l);
24     }
25     return 0;
26 }

 

posted @ 2014-11-09 11:02  NicoleLam  阅读(242)  评论(0编辑  收藏  举报