提交时间:2024-04-16 16:50:37
运行 ID: 143569
#include<bits/stdc++.h> using namespace std; int l,r,ans1=0,ans2=0; 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(){ cin>>l>>r; for(int i=l;i<=r;i++){ if(check(i))ans1++; else ans2++; } cout<<ans1<<" "<<ans2; return 0; }