您的位置:首页 > 大数据 > 人工智能

Codeforces 579A. Raising Bacteria(位运算)

2016-04-22 17:58 483 查看
You are a lover of bacteria. You want to raise some bacteria in a box.

Initially, the box is empty. Each morning, you can put any number of bacteria into the box. And each night, every bacterium in the box will split into two bacteria. You hope to see exactly xbacteria
in the box at some moment.

What is the minimum number of bacteria you need to put into the box across those days?

Input

The only line containing one integer x (1 ≤ x ≤ 109).

Output

The only line containing one integer: the answer.

Examples

input
5


output
2


input
8


output

1

solution:

找一下n的二进制中1的个数

#include<cstdio>
using namespace std;
int main()
{
int n,ans=0;
scanf("%d", &n);
while (n)
{
if (n & 1)ans++;
n >>= 1;
}
printf("%d\n", ans);
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: