HDU-5272
Dylans loves numbers
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 201 Accepted Submission(s): 136
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.
T is the test number.
In the next T lines there is a number N.
0≤N≤1018,T≤1000
/**
题意:给出一个数,然后求该数的二进制的有多少组1
比如10101 1101101 都是三组
做法:暴力 还有如果计算一个数的二进制有多少1
可以
while(n)
{
count++;
n = n&(n-1);
}
**/
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
//#ifndef ONLINE_JUDGE
// freopen("in.txt","r",stdin);
//#endif // ONLINE_JUDGE
int T;
scanf("%d",&T);
while(T--)
{
long long n;
long long sum = ;
int tt = ;
scanf("%lld",&n);
int cnt = ;
while(n)
{
cnt = n % ;
if(tt == && cnt == ) sum++;
n /= ;
tt = cnt;
}
printf("%lld\n",sum);
}
return ;
}
HDU-5272的更多相关文章
- hdu 5272 Dylans loves numbers
题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=5272 Dylans loves numbers Description Who is Dylans?Y ...
- hdu 5272 Dylans loves numbers 水题
Dylans loves numbers Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem. ...
- HDOJ 2111. Saving HDU 贪心 结构体排序
Saving HDU Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total ...
- 【HDU 3037】Saving Beans Lucas定理模板
http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...
- hdu 4859 海岸线 Bestcoder Round 1
http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...
- HDU 4569 Special equations(取模)
Special equations Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u S ...
- HDU 4006The kth great number(K大数 +小顶堆)
The kth great number Time Limit:1000MS Memory Limit:65768KB 64bit IO Format:%I64d & %I64 ...
- HDU 1796How many integers can you find(容斥原理)
How many integers can you find Time Limit:5000MS Memory Limit:32768KB 64bit IO Format:%I64d ...
- hdu 4481 Time travel(高斯求期望)(转)
(转)http://blog.csdn.net/u013081425/article/details/39240021 http://acm.hdu.edu.cn/showproblem.php?pi ...
- HDU 3791二叉搜索树解题(解题报告)
1.题目地址: http://acm.hdu.edu.cn/showproblem.php?pid=3791 2.参考解题 http://blog.csdn.net/u013447865/articl ...
随机推荐
- sass的mixin,extend,placeholder,function
1. mixin 就是定义了一个函数,可以传参,并且设定默认值,css选择器可以通过@include来引用,mixin混入的代码,就是原样复制,不会合并,会造成冗余 例如: @mixin br6($b ...
- luoguP1357 花园
矩阵乘法优化dp 注意环形处理: 发现,对于一个初始状态s的方案数,就是填n次后,再回到自己的状态.期间都是合法的话,那么一定这个方案就合法. 和开始状态有关.所以先把状态转移矩阵的(n-m)乘出来. ...
- Poco::Path 和 DirectoryIterator
#include<iostream>#include<typeinfo>#include<Poco/Path.h>using namespace std;using ...
- Uva-oj Product 大数乘法
Product Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Des ...
- bzoj 1135 [POI2009]Lyz 线段树+hall定理
1135: [POI2009]Lyz Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 573 Solved: 280[Submit][Status][ ...
- bzoj 4488 [Jsoi2015]最大公约数 结论+暴力
[Jsoi2015]最大公约数 Time Limit: 10 Sec Memory Limit: 256 MBSubmit: 302 Solved: 169[Submit][Status][Dis ...
- MongoDB入门(1)- MongoDB简介
什么是MongoDB NoSQL NoSQL systems are also sometimes called "Not only SQL" to emphasize that ...
- 洛谷 P1976 鸡蛋饼
题目背景 Czyzoiers 都想知道小 x 为什么对鸡蛋饼情有独钟.经过一番逼问,小 x 道出 了实情:因为他喜欢圆. 题目描述 最近小 x 又发现了一个关于圆的有趣的问题:在圆上有2N 个不同的点 ...
- IntentServicce;Looper;long-running task
7. If you want to carry on a long-running task, what do you need to do? IntentService:Service Servic ...
- 【BZOJ3769】BST again [DP]
BST again Time Limit: 10 Sec Memory Limit: 256 MB[Submit][Status][Discuss] Description 求有多少棵大小为n的深度 ...