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?

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

Note

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.

题解:水题;

参考代码:

 #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;
typedef pair<int,int> PII;
#define PI acos(-1)
#define EPS 1e-8
const int INF=0x3f3f3f3f;
const LL inf=0x3f3f3f3f3f3f3f3fLL;
const int maxn=1e5+; int main()
{
int n;
while(~scanf("%d",&n))
{
int cnt=;
for(int t=;t<=n;t*=)
{
if((t&n)!=) cnt++,n-=t;
}
printf("%d\n",cnt);
}
return ;
}

CF579 - A Raisinng bacteria的更多相关文章

  1. Codeforces__Raising Bacteria

    题目传送门:Raising Bacteria //问题描述:一个盒子里面放一个细菌在一天可以增生两个细菌. 现在已知盒子里面细菌的个数,问你最初放多少个细菌可以增生盒子里面的细菌数量 //输入:盒子中 ...

  2. Codeforces 579A. Raising Bacteria

    You are a lover of bacteria. You want to raise some bacteria in a box. Initially, the box is empty. ...

  3. Gym - 101911C Bacteria (规律题)

    传送门:点我 Time limit2000 ms Memory limit262144 kB Recently Monocarp has created his own mini-laboratory ...

  4. LightOJ 1220 Mysterious Bacteria(唯一分解定理 + 素数筛选)

    http://lightoj.com/volume_showproblem.php?problem=1220 Mysterious Bacteria Time Limit:500MS     Memo ...

  5. Codeforces Round #320 (Div. 2) [Bayan Thanks-Round] A. Raising Bacteria【位运算/二进制拆分/细胞繁殖,每天倍增】

    A. Raising Bacteria time limit per test 1 second memory limit per test 256 megabytes input standard ...

  6. Bacteria (Gym - 101911C)

    2018-2019 ACM-ICPC, NEERC, Southern Subregional Contest, Qualification Stage Bacteria Gym - 101911C ...

  7. LightOJ - 1341 Aladdin and the Flying Carpet 唯一分解定理LightOJ 1220Mysterious Bacteria

    题意: ttt 组数据,第一个给定飞毯的面积为 sss,第二个是毯子的最短的边的长度大于等于这个数,毯子是矩形但不是正方形. 思路: 求出 sss 的所有因子,因为不可能是矩形,所以可以除以 222, ...

  8. LightOj 1220 - Mysterious Bacteria (分解质因子x=b^p 中的 x 求最大的 p)

    题目链接:http://lightoj.com/volume_showproblem.php?problem=1220 题意:已知 x=bp 中的 x 求最大的 p,其中 x b p 都为整数 x = ...

  9. Codeforces400D Dima and Bacteria

    题意:给你一个无向有权的图,图上的点被分成了几类,对于同类的点你需要判断它们之间相互的最短距离是不是0.满足这个条件之后要输出的是类与类之间的最短距离的矩阵.点给到10^5这么多,判断同类的点显然不能 ...

随机推荐

  1. python 豆瓣top250电影的爬取

    我们先看一下豆瓣的robot.txt 然后我们查看top250的网页链接和源代码 通过对比不难发现网页间只是start数字发生了变化. 我们可以知道电影内容都存在ol标签下的 div class属性为 ...

  2. nuxt遇到的问题(一)window 或 document is not defined

    因为用了VUE做的官网,既然是官网了避免不了SEO的问题了(该死当初就不应该选择用vue) 很自然就是选择了使用nuxt.js来做ssr预渲染了. 因为网站不是响应式的,PC / 移动端要进行对应跳转 ...

  3. nyoj 77-开灯问题 (倍数遍历)

    77-开灯问题 内存限制:64MB 时间限制:3000ms 特判: No 通过数:13 提交数:24 难度:1 题目描述: 有n盏灯,编号为1~n,第1个人把所有灯打开,第2个人按下所有编号为2 的倍 ...

  4. TreeMap的源码学习

    TreeMap的源码学习 一).TreeMap的特点 根据key值进行排序. 二).按key值排序的两种排序算法实现 1).在构造方法中传入比较器 public TreeMap(Comparator& ...

  5. vue项目页面切换到默认显示顶部

    页面切换到默认显示顶部 方法一 使用前端路由,当切换到新路由时,想要页面滚到顶部,或者是保持原先的滚动位置,就像重新加载页面那样. vue-router 能做到,而且更好,它让你可以自定义路由切换时页 ...

  6. MYSQLnavicat绿色版工具下载

    MYSql远程连接工具navicat工具:https://pan.baidu.com/s/1RU_8FCX7yCseAFRhn4voAQ

  7. [Odoo12基础教程]之第一篇-创建Todo应用

    声明: 本教程基于 Ruter 老师的 [Odoo基础教程系列] ,Ruter老师教程的链接地址为:Odoo基础教程系列   . 至于为什么已经有了Ruter老师的教程,还要自己再搬移一份呢?是基于一 ...

  8. Python-Re正则表达式库

    来源:中国MOOC北京理工大学Python教学团队 链接:https://www.icourse163.org/learn/BIT-1001870001#/learn/content?type=det ...

  9. Python 0基础开发游戏:打地鼠(详细教程)VS code版本

    如果你没有任何编程经验,而且想尝试一下学习编程开发,这个系列教程一定适合你,它将带你学习最基本的Python语法,并让你掌握小游戏的开发技巧.你所需要的,就是付出一些时间和耐心来尝试这些代码和操作. ...

  10. IdentityServer4 保护.net framework webapi

    一.IS4服务器配置 1.新建一个Asp.net  Core MVC程序,模板选择 Empty 2.Nuget添加 IdentityServer4,我这里添加的是2.5.3 3.添加Config文件, ...