Quantcast
Channel: CSDN博客推荐文章
Viewing all articles
Browse latest Browse all 35570

10718 - Bit Mask

$
0
0
描述:题意很简单,可是如果要从L到U之间用 | 遍历的话会超时,只能换种思路了
#include <cstdio>
#include <cstdlib>
int main()
{
 //   freopen("a.txt","r",stdin);
    int n,l,u;
    unsigned int m;
    while(scanf("%d%d%d",&n,&l,&u)!=EOF)
    {
        m=0;
        for(int i=31; i>=0; i--)
            if(m+ (1<<i) <=u&&( (n& (1<<i) ) ==0||( m<l&& (l& (1<<i) )  ) ) ) m+=(1<<i);
        printf("%u\n",m);
    }
    return 0;
}

作者:moyan_min 发表于2013-3-26 0:08:13 原文链接
阅读:104 评论:0 查看评论

Viewing all articles
Browse latest Browse all 35570

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>