1 条题解

  • 0
    @ 2025-5-7 20:11:41

    打表+二分即可

    #include <bits/stdc++.h>
    using namespace std;
    #define faster ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
    typedef long long ll; ll n;
    vector<ll>v={1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216};
    ll cntl,cnta,ans; 
    
    void solve(){
    	ll r,l;
    	cin>>l>>r;
    	auto pos_l=lower_bound(v.begin(),v.end(),l); 
    	auto pos_r=upper_bound(v.begin(),v.end(),r);
    	ll len=pos_r-pos_l;
    	cout<<len;
    }
    int main(){
    	faster;
    	ll T=1;
    	while(T--)solve();
    	return 0;
    }
    
    • 1

    信息

    ID
    96
    时间
    1000ms
    内存
    256MiB
    难度
    2
    标签
    递交数
    50
    已通过
    30
    上传者