#include <iostream>
using namespace std;
int A, B, cnt0, cnt1;
int main()
{
int n, t, temp;
cin >> n;
for (int i = 1; i <= n; i++) {
cnt0 = 0, cnt1 = 0;
t = i;
while (t) {
temp = t & 1;
t = t >> 1;
if (temp)
cnt1++;
else
cnt0++;
}
if(cnt1 > cnt0)
{
A++;
}
else
{
B++;
}
}
cout << A << ' ' << B;
return 0;
}
洛谷-二进制数转换和对比&
猜你喜欢
转载自blog.csdn.net/weixin_52045928/article/details/121548161
今日推荐
周排行