题目连接

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. asp.net 配置 X-Frame-Options

    近日网站在安全检查,送检的网站被反馈有以下问题 X-Frame-Options Header未配置 漏洞描述: 弱点描述: X-Frame-Options HTTP响应头可以指示浏览器是否允许当前网页 ...

  2. rsync拉取远程文件

    mkdir -p   /doc sshpass -p ''pwd" rsync -avz -e 'ssh -o UserKnownHostsFile=/dev/null -o StrictH ...

  3. No.011 Container With Most Water

    11. Container With Most Water Total Accepted: 86363 Total Submissions: 244589 Difficulty: Medium Giv ...

  4. No.008 String to Integer (atoi)

    8. String to Integer (atoi) Total Accepted: 112863 Total Submissions: 825433 Difficulty: Easy Implem ...

  5. 用Scrapy爬虫下载图片(豆瓣电影图片)

    用Scrapy爬虫的安装和入门教程,这里有,这篇链接的博客也是我这篇博客的基础. 其实我完全可以直接在上面那篇博客中的代码中直接加入我要下载图片的部分代码的,但是由于上述博客中的代码已运行,已爬到快九 ...

  6. Artifacts Gallery - Seahorse Collector, The

    Artifacts Gallery - Seahorse Collector, The

  7. HTML中,按钮button与submit区别是什么?

    type=button 单纯是按钮功能:type=submit 是发送表单:既然是这样,那么能否全部用submit代替button? Sumit提交表单,Button需要绑定事件才可以用提交数据不可以 ...

  8. 前端开发中的SEO

    什么是SEO SEO由英文Search Engine Optimization缩写而来,中文意译为"搜索引擎优化".SEO是指从自然搜索结果获得网站流量的技术和过程,是在了解搜索引 ...

  9. 著名的二分查找的BUG

    int binarySearch(int a[], int key, int length) { int low = 0; int high = length - 1; while (low < ...

  10. 说一个Sublime Text 2插件、emmet(原名:zen Coding)

    工具/原料 sublime Text 2 安装emmet插件 方法/步骤 生成html文档初始结构: !<tab> <!doctype html> <html lang= ...