提交时间:2023-08-22 08:11:54
运行 ID: 99104
#include<bits/stdc++.h> using namespace std; int l,r; bool check(int x){ int a=0,b=0; while(x!=0){ if(x&1){a++;} else{ b++;} x=x>>1;} return a>b;} int main(){ int ans1=0,ans2=0; cin>>l>>r; for(int i=l;i<=r;i++){ if(check(i)) ans1++; else ans2++;} cout<<ans1<<" "<<ans2<<endl; return 0; }