luogu CF484Aビット|数学

タイトルの翻訳

  • \(n \)グループクエリ、間隔\(l、r \)が指定されるたびに、この間隔のバイナリ表現で1の最大数を持つ数を出力する必要があります

  • 複数の回答がある場合は、最小の回答を出力します

  • \((n \ leq10 ^ 4、0 \ leq l、r \ leq10 ^ {18})\)


#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int mod=1e9+7,N=2e5+10;
#define int long long
int n,l,r;
signed main(){
	cin>>n;
	while(n--){
		scanf("%lld%lld",&l,&r);
		for(int i=1;(l|i)<=r;i<<=1)l|=i;
		printf("%lld\n",l);
	}
}

おすすめ

転載: www.cnblogs.com/naruto-mzx/p/12689500.html