coderforce 484A Bits(强大的位运算)

题意:求区间中m-n中每个数转换成二进制中一的个数最多的一个
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
#define LL long long
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        LL m,n;
        scanf("%lld%lld",&m,&n);
        LL x=1;
        while((m|x)<=n)
        {
            m|=x;
            x<<=1;
        }
        printf("%lld\n",m);
    }
    return 0;
}

你可能感兴趣的:(coderforce 484A Bits(强大的位运算))