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

来源:互联网 发布:淘宝网现状 编辑:程序博客网 时间:2024/06/05 23:51
题意:求区间中m-n中每个数转换成二进制中一的个数最多的一个
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;#define LL long longint 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;}

1 0
原创粉丝点击