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. C#索引器与数组的区别

    1.索引器的索引值类型不限定为整数 2.索引器允许重载 3.索引器不是一个变量 4.索引器以函数签名方式this标识,而属性采用名称来标识,名称可以任意 5.索引器不能使用static来进行声明,属性 ...

  2. BST的实现(二叉搜索树)

    void Inorder(struct Tree *T); //中序 void Preorder(struct Tree *T); //前序 void Postorder(struct Tree *T ...

  3. 关于jQuery easyUI 添加合计统计行

    首先在onLoadSuccess中添加计算函数:计算方法按各自业务需要,我做了一个判断非数 然后再在gatagrid表格添加行,$('#div').datagrid('appendRow', {... ...

  4. WordPress 添加title中的logo

    WordPress 添加title中的logo <!--网页标题左侧显示--> <link rel="icon" href="/favicon.png& ...

  5. nyoj 4 ASCII码排序

    ASCII码排序 时间限制:3000 ms  |  内存限制:65535 KB | 难度:2   描述 输入三个字符(可以重复)后,按各字符的ASCII码从小到大的顺序输出这三个字符.   输入 第一 ...

  6. 目录(cd mkdir rmdir rm pwd ls) 文件(ln touch mv rm cat more head rail) 文件权限(chmod chown chgrp) 文件通配符(* ? [])

    记住Linux目录树的结构是一个称职Linux系统管理员的必备素质! 目录漫游cd   cd - 目录显示pwd 目录管理 mkdir -p a/b/c/1 parent创建多层目录 -m 700   ...

  7. VLAN配置及Trunk接口配置

    实验拓扑 1.检验连通性,PC2 ping PC3,PC2 ping PC4 ,都能ping 通 2.创建vlan 3.配置access接口 在S1上配置E0/0/2为vlan10和E0/0/3为vl ...

  8. 配置k8s集群context-rbac实践

    说明 在openshift环境中,可以通过oc project {project_name}命令来切换project,那么在k8s中式如何切换namespace的呢?(ocp的project即相当于k ...

  9. python爬取中国知网部分论文信息

    爬取指定主题的论文,并以相关度排序. #!/usr/bin/python3 # -*- coding: utf-8 -*- import requests import linecache impor ...

  10. 菜鸟系列Fabric源码学习 — peer节点启动

    Fabric 1.4 源码分析peer节点启动 peer模块采用cobra库来实现cli命令. Cobra提供简单的接口来创建强大的现代化CLI接口,比如git与go工具.Cobra同时也是一个程序, ...