【每日一题】兔子的区间密码
兔子的区间密码
https://ac.nowcoder.com/acm/problem/20860
题意:
思路:
#include <cstdio> using namespace std; typedef long long ll; ll l,r; ll highbit(ll x){ ll res = x,cur = x; while(cur){ res = cur; cur &= res - 1; } return res; } int main(){ int t;scanf("%d",&t); while(t--){ scanf("%lld%lld",&l,&r); if(l == r) {puts("0");continue;} ll x = l^r; x = highbit(x); printf("%lld\n",(x<<1ll) - 1); } return 0; }
每日一题 文章被收录于专栏
每题一题题目