Codeforces Round #320 (Div. 2) A. Raising Bacteria
来源:互联网 发布:lte弱覆盖优化 编辑:程序博客网 时间:2024/05/21 11:36
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 x bacteria in the box at some moment.
What is the minimum number of bacteria you need to put into the box across those days?
The only line containing one integer x (1 ≤ x ≤ 109).
The only line containing one integer: the answer.
5
2
8
1
For the first sample, we can add one bacterium in the box in the first day morning and at the third morning there will be 4 bacteria in the box. Now we put one more resulting 5 in the box. We added 2 bacteria in the process so the answer is 2.
For the second sample, we can put one in the first morning and in the 4-th morning there will be 8 in the box. So the answer is 1.
分析:求二进制中1的个数
- Codeforces Round #320 (Div. 2) A. Raising Bacteria
- Codeforces Round #320 (Div. 2) 579A Raising Bacteria(脑洞)
- Codeforces Round #320 (Div. 2) 579A. Raising Bacteria
- Codeforces Round #320 (Div. 2) A. Raising Bacteria
- Codeforces Round #320 (Div. 2) [Bayan Thanks-Round]A Raising Bacteria
- Raising Bacteria (Codeforces Round #320 (Div. 2) [Bayan Thanks-Round] )
- cf#320 Div.2 Problem A Raising Bacteria
- Codeforces 320A - Raising Bacteria(思维)
- CodeForces 579A - Raising Bacteria
- CodeForces 579A Raising Bacteria
- codeforces 579A Raising Bacteria
- Raising Bacteria CodeForces - 579A
- codeforces #320 div2A Raising Bacteria
- CodeForces 579A Raising Bacteria (水)
- Codeforces 579A. Raising Bacteria(位运算)
- Codeforces Round #125 (Div. 1) A. About Bacteria
- A. Raising Bacteria
- Codeforces Round #125 (Div. 2) / C. About Bacteria
- 矩阵乘法的意义
- 经典排序算法总结与实现
- CF#320 Div.2 总结
- Mac下ShadowSockets全局设置转http代理
- Android shape的使用
- Codeforces Round #320 (Div. 2) A. Raising Bacteria
- tomcat maven的热部署
- Leetcode House Robber II
- perfect squares find the least number of perfect square numbers (1, 4, 9, 16, ...) which sum to n
- Codeforces Round #320 (Div. 2)C. A Problem about Polyline
- 我的成长(三)---沟通真的很重要
- java网络编程【精简篇】
- 条款30 透彻了解inlining的里里外外
- longest increasing continuous subsequence in a 2D matrix