Codeforces 579A. Raising Bacteria(位运算)
来源:互联网 发布:海淘比价软件 编辑:程序博客网 时间:2024/06/06 16:19
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;}
0 0
- Codeforces 579A. Raising Bacteria(位运算)
- CodeForces 579A - Raising Bacteria
- CodeForces 579A Raising Bacteria
- codeforces 579A Raising Bacteria
- Raising Bacteria CodeForces - 579A
- Code Forces 579 A. Raising Bacteria(位运算)
- CodeForces 579A Raising Bacteria (水)
- Codeforces Round #320 (Div. 2) 579A Raising Bacteria(脑洞)
- Codeforces Round #320 (Div. 2) 579A. Raising Bacteria
- codeforces—— 579A —— Raising Bacteria
- coderforce 579A Raising Bacteria
- Codeforces 320A - Raising Bacteria(思维)
- A. Raising Bacteria
- Codeforces Round #320 (Div. 2) A. Raising Bacteria
- Codeforces Round #320 (Div. 2) A. Raising Bacteria
- codeforces #320 div2A Raising Bacteria
- Codeforces Round #320 (Div. 2) [Bayan Thanks-Round]A Raising Bacteria
- Raising Bacteria
- linux cpu居高不下 调试
- 我和我的伙伴如何用具体的代码
- 小技巧 让导航栏变透明
- 蓝桥杯 历届试题 带分数
- 判断一个树是否为另一个树的子树
- Codeforces 579A. Raising Bacteria(位运算)
- poj 2240 Arbitrage
- 二维码扫描
- 【bzoj2648】【sjy摆棋子】【kd树】
- 深度学习新算法,完成字里行间的情绪识别
- Codeforces 558C. Amr and Chemistry(暴搞)
- Android自定义View 之 View的测量
- 我和我的同伴是如何用具体的代码
- Linux 系统裁剪笔记1