题目连接

http://acm.hdu.edu.cn/showproblem.php?pid=5272

Dylans loves numbers

Description

Who is Dylans?You can find his ID in UOJ and Codeforces.
His another ID is s1451900 in BestCoder.

And now today's problems are all about him.

Dylans is given a number $N.$
He wants to find out how many groups of "1" in its Binary representation.

If there are some "0"(at least one)that are between two "1",
then we call these two "1" are not in a group,otherwise they are in a group.

Input

In the first line there is a number $T.$

$T$ is the test number.

In the next $T$ lines there is a number $N.$

$0 \leq N \leq 10^{18},T \leq 1000$

Output

For each test case,output an answer.

SampleInput

1

5

SampleOutput

2

 #include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
using std::cin;
using std::cout;
using std::endl;
using std::find;
using std::sort;
using std::set;
using std::map;
using std::pair;
using std::vector;
#define sz(c) (int)(c).size()
#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cls(arr,val) memset(arr,val,sizeof(arr))
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
const int Max_N = ;
typedef unsigned long long ull;
int main() {
#ifdef LOCAL
freopen("in.txt","r",stdin);
freopen("out.txt","w+",stdout);
#endif
int t;
ull ret;
scanf("%d",&t);
while(t--) {
int f = , ans = ;;
scanf("%lld",&ret);
while(ret) {
if(f) {
if(ret & ) ans++, f = ;
} else if(!(ret & )) f = ;
ret >>= ;
}
printf("%d\n",ans);
}
return ;
}

hdu 5272 Dylans loves numbers的更多相关文章

  1. hdu 5272 Dylans loves numbers 水题

    Dylans loves numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem. ...

  2. HDU 5273 Dylans loves numbers(水题)

    题意:给出一个0≤N≤1018,求其二进制中有几处是具有1的,假设相连的1只算1处,比如1101011就是3处. 思路:一个个数,当遇到第一个1时就将flag置为1:当遇到0就将flag置为0.当遇到 ...

  3. hdu 5274 Dylans loves tree(LCA + 线段树)

    Dylans loves tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Othe ...

  4. Hdu 5274 Dylans loves tree (树链剖分模板)

    Hdu 5274 Dylans loves tree (树链剖分模板) 题目传送门 #include <queue> #include <cmath> #include < ...

  5. hdu 5273 Dylans loves sequence

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5273 Dylans loves sequence Description Dylans is give ...

  6. hdu 5274 Dylans loves tree

    Dylans loves tree http://acm.hdu.edu.cn/showproblem.php?pid=5274 Time Limit: 2000/1000 MS (Java/Othe ...

  7. hdu 5273 Dylans loves sequence 逆序数简单递推

    Dylans loves sequence Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem ...

  8. hdu 5274 Dylans loves tree (树链剖分 + 线段树 异或)

    Dylans loves tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Othe ...

  9. HDU 5273 Dylans loves sequence 暴力递推

    题目链接: hdu:http://acm.hdu.edu.cn/showproblem.php?pid=5273 bc:http://bestcoder.hdu.edu.cn/contests/con ...

随机推荐

  1. javascript代码复用模式(三)

    前面谈到了javascript的类式继承.这篇继续部分类式继承,及一些现代继承. 类式继承模式-代理构造函数 这种模式通过断开父对象与子对象之间原型之间的直接链接关系,来解决上次说到的共享一个原型所带 ...

  2. 【drp 10】JSP页面中model1和model2的区别

    一.基本概念 1.1,model1 model1的开发模式是:jsp+javabean的模式,它的核心是JSP页面,在这个页面中,jsp页面负责整合页面和javabean(业务逻辑),而且渲染页面.它 ...

  3. 【EF 5】结合项目实战分析EF三大工作模式之—Database First

    导读:所谓的EF的Databasefirst工作模式,是目前我们(不涉及社会领域)用的最广的一种模式,也是本次ITOO开发所采用的工作模式.本篇博客,就分析在项目中通过Database First模式 ...

  4. SSIS Error Code DTS_E_OLEDB_NOPROVIDER_64BIT_ERROR

    将一批Job从一台agent服务器搬到另外一台agent, 没有做任何的修改,但是job执行的时候报错. Error: 2014-07-03 14:42:57.14 Code: 0xC0209303 ...

  5. 多行文字垂直居中(完美兼容chrome firefox IE6 7 8 9)

    在说到这个问题的时候,也许有人会问CSS中不是有vertical-align属性来设置垂直居中的吗?即使是某些浏览器不支持我只需做少许的CSS Hack技术就可以啊!所以在这里我还要啰嗦两句,CSS中 ...

  6. 在python3.5中使用pip

    我centos7上同时有python2.7和python3.5.现在希望能在使用python3.5时也能用pip.本来这应该是很容易的一件事,然而我一步步掉进坑里.. 官网安装pip的方法是,http ...

  7. CSS 之 Opacity多浏览器透明度兼容处理

    用来设定元素透明度的 Opacity 是CSS 3里的一个属性.当然现在还只有少部分浏览器支持. 不过各个浏览器都有自己的私有属性来支持,其中包括老版本的Mozilla和Safari: IE: fil ...

  8. oracle split

    select * from table(fun_strsplit('1,2,3,4,5')); 1.创建一个类型 ) 2.创建函数 CREATE OR REPLACE FUNCTION Fun_Str ...

  9. 理解DOM中的事件流

    浏览器发展到第四代时(IE4和Netscape Communicator 4),浏览器团队遇到一个很有意思的问题:页面的哪一部分会拥有特定的事件?想象下在一张纸上有一组同心圆,如果你把手指放在圆心上, ...

  10. iOS自动布局一

    Align: Pin: