国防科大校赛决赛-final(镜像赛) Problem B: XueXX and Binary
来源:互联网 发布:c语言buffer 编辑:程序博客网 时间:2024/05/19 19:59
Description
XueXX is a clever boy. And he always likes numbers in binary(二进制). What an interesting hobby!
Now XueXX has some number in decimal(十进制), he wants to know how many “1”s in a number if the number is written in binary.
Input
The first line of input contains the number of test cases T (T<=100). The descriptions of the test cases follow: The first line of each test case contains one integer a (0
#include<iostream>#include<string>#include<algorithm>using namespace std; int main() { int t; cin>>t; while(t--) { int n,ans=0; cin>>n; while(n) { n&=n-1; ans++; } cout<<ans<<endl; } return 0; }
0 0
- 国防科大校赛决赛-final(镜像赛) Problem B: XueXX and Binary
- 国防科大校赛决赛-final(镜像赛) Problem C: XueXX and Chessboard
- 国防科大校赛决赛-final(镜像赛) Problem A: XueXX and P-P String
- csuoj-1732-XueXX and Binary
- ACM L: XueXX and Binary
- 国防科大校赛I题: Prime Summation
- CSU1732-XueXX and Binary-简单模拟
- 武大校赛网络赛B题
- 湖南多校对抗赛(2015.05.10)(国防科大学校赛决赛-Semilive)E
- 湖南多校对抗赛(2015.05.10)(国防科大学校赛决赛-Semilive)G
- csuoj-1733-XueXX and Chessboard
- TOJ3583A and B Problem
- WOJ 武大校赛 Problem 1537 - A - Stones I
- 2015浙工大校赛-Problem K: 数圈圈
- zqoj 1815: easy problem 【打表】【郑大校赛】
- 【辛普森积分*模板】2017河工大校赛 B地狱飞龙
- GDUT决赛 - Problem B: 完美串(DP`LCS)
- 2016广东工业大学新生杯决赛:Problem B: Zhazhahe究竟有多二
- 关于java.sql.SQLException: Access denied for user 'root'@'localhost' (using password Yes)
- 高斯模糊的算法
- javaweb学习总结(4)------Http协议
- LinuxKernel 入侵式双向链表的设计,分析,使用
- ConvertStore
- 国防科大校赛决赛-final(镜像赛) Problem B: XueXX and Binary
- ConvertAction
- spring配置
- ConvertFromAction
- C/C++对文件的读写
- 如何设置幻灯片自动播放
- ecshop邮件服务器设置注意事项
- ConvertToAction
- 有疑问