CF 579A (二进制拆分)
2024-09-02 04:39:58
在培养皿中,每个细胞每天会繁殖,数量*2
我们可以在任意天加入任意数量的细胞入培养皿中。
想要知道最少加入多少个细胞,可以使得有一天,培养皿中细胞的数量会恰好为x
其实就是输出X的二进制中有多少个1
Sample test(s)
input
5
output
2
input
8
output
1
# include <iostream>
# include <cstdio>
# include <cstring>
# include <algorithm>
# include <string>
# include <cmath>
# include <queue>
# include <list>
# define LL long long
using namespace std ; int main()
{
//freopen("in.txt","r",stdin) ;
int n ;
while(scanf("%d",&n) != EOF)
{
int sum = ;
while(n)
{
if (n & )
sum++ ;
n >>= ;
}
printf("%d\n" , sum) ;
} return ;
}
最新文章
- linux mount/umount挂载命令解析。
- 安全测试 - XSS如何防御
- Python迭代器,可迭代对象,生成器
- jquery为新增元素添加事件
- Tomcat+eclipse JSP windows开发环境配置
- BI案例:某公司BI系统的九大主题分析
- Jquery基础:append、prepend、after、before、appendTo的区别
- REST内容协商注解
- 导航控制器生产,push,pop,root,index
- nginx安装与应用
- 终于知道如何使Tab控件的不出现白边的方法了
- C# 处理Word自动生成报告 三、设计模板
- vue 项目中引用百度地图
- tomcat catalina.out乱码
- Spring_AOP 实现原理与 CGLIB 应用
- 微软Azure AspNetCore微服务实战 第二期
- sga 操作命令
- zookeeper3.4.5+Hbase1.2.6安装教程
- 【jdk源码1】TreeMap源码学习
- asp.net Ibatis.net 批量插入数据ORACLE