#include<iostream>
#include<vector>
#include<set>
using namespace std;
int main()
{
int n,m;
int res = 0;
cin >> n >> m;
while (n != 0)
{
n = n & (n - 1);
res++;
}
cout << "F1:"<<res << endl;
res = 0;
while(m!=0)
{
int x = m&1;
if(x == 1)
{
res++;
}
m = m >> 1;
}
cout << "F2:" << res << endl;
return 0;
}
LeetCode401二进制手表 总结C++统计整数中的“1”的个数方法
最新推荐文章于 2020-07-15 12:15:34 发布