感觉代码没问题,样例也过了……
#include<bits/stdc++.h>
using namespace std;
int n,suma,sumb;
bool chk(int x){
int a,b;
while(x){
if(x&1) a++;
else b++;
x/=2;
}
if(a>b) return true;
else return false;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
if(chk(i)) suma++;
else sumb++;
}
cout<<suma<<' '<<sumb;
}