10718 - Bit Mask
[cpp]描述:题意很简单,可是如果要从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;}
补充:软件开发 , C++ ,