2 条题解

  • 0
    @ 2026-3-12 19:16:27

    正确的写法是位运算~~ 左移即可

    #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;ll cntl,cnta;const ll N=1e3+5; 
    ll a[N]; ll T=1;
    void solve(){
    	ll l,r;cin>>l>>r;
    	ll x=1;
    	while(x<=r){
    		if(x>=l)cntl++;
    		x=x<<1;
    	}
    	 cout<<cntl;
    }
    int main(){
    	faster;
    	while(T--)solve();
    	return 0;
    }
    
    

    信息

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