UVALive 6527 Counting ones dfs(水
题目链接:点击打开链接
#include <cstdio>
#include <vector>
using namespace std;
typedef long long ll;
ll re;
vector<int> p;
void dfs(int dep, int g) {
if (dep == 0)
return ;
if (p[dep-1] == 1) {
re += (dep-1) * (1ll<< (dep-2));
re += g * (1ll << (dep-1));
}
dfs(dep-1, g+p[dep-1]);
}
ll C(ll x) {
if (x == 0)
return 0;
p.clear();
re = 0;
while (x>0) {
p.push_back(x%2);
x /= 2;
}
for (int i = 0; i < (int)p.size(); ++i)
re += p[i];
dfs(p.size(), 0);
return re;
}
int main() {
ll A, B;
while (~scanf("%lld%lld", &A, &B))
printf("%lld\n", C(B) - C(A-1));
return 0;
}
UVALive 6527 Counting ones dfs(水的更多相关文章
- poj1564 Sum It Up dfs水题
		
题目描述: Description Given a specified total t and a list of n integers, find all distinct sums using n ...
 - Openjudge1388  Lake Counting【DFS/Flood Fill】
		
http://blog.csdn.net/c20182030/article/details/52327948 1388:Lake Counting 总时间限制: 1000ms 内存限制: ...
 - POJ2386 Lake Counting 【DFS】
		
Lake Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 20782 Accepted: 10473 D ...
 - POJ_2386 Lake Counting (dfs 错了一个负号找了一上午)
		
来之不易的2017第一发ac http://poj.org/problem?id=2386 Lake Counting Time Limit: 1000MS Memory Limit: 65536 ...
 - hdu 3887  Counting Offspring dfs序+树状数组
		
Counting Offspring Time Limit: 15000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Othe ...
 - 【wikioi】1229 数字游戏(dfs+水题)
		
http://wikioi.com/problem/1229/ 赤裸裸的水题啊. 一开始我认为不用用完全部的牌,以为爆搜会tle.. 可是我想多了. 将所有状态全部求出,排序后暴力判断即可. (水题有 ...
 - HDU 2952 Counting Sheep(DFS)
		
题目链接 Problem Description A while ago I had trouble sleeping. I used to lie awake, staring at the cei ...
 - Oil Deposits(dfs水)
		
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1241 Oil Deposits Time Limit: 2000/1000 MS (Java/Othe ...
 - Poj2386 Lake Counting (DFS)
		
Lake Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 49414 Accepted: 24273 D ...
 
随机推荐
- 题解 P3605 【[USACO17JAN]Promotion Counting晋升者计数】
			
这道题开10倍左右一直MLE+RE,然后尝试着开了20倍就A了...窒息 对于这道题目,我们考虑使用线段树合并来做. 所谓线段树合并,就是把结构相同的线段树上的节点的信息合在一起,合并的方式比较类似左 ...
 - 【Codeforces Round #422 (Div. 2) C】Hacker, pack your bags!(二分写法)
			
[题目链接]:http://codeforces.com/contest/822/problem/C [题意] 有n个旅行计划, 每个旅行计划以开始日期li,结束日期ri,以及花费金钱costi描述; ...
 - vmware下ubuntu的网络配置
			
捣弄了vmnet0和vmnet8连接后,ubuntu上不了网了,今天突然解决了这个问题. 打开vmware后,点编辑-->虚拟网络编辑器 这里我使用的是NAT模式,所以要修改vmnet8 点vm ...
 - 基于请求响应的MVC框架调用分析
			
一.使用Servlet来处理请求响应 当client提交数据之后.接着发送请求,请求被封装成对象,server接收到请求,依据请求的URL.来推断将请求对象交由哪个Servlet处理. 在servle ...
 - 分析一下jquery中的ajax操作
			
在web前端开发中,ajax是很重要的一项技术,用原生写起来很是麻烦,需要一大堆js代码,而到了jq里就被精简了许多,一起来看看: jquery中的ajax分为三种方式: 1.$.get(),get方 ...
 - VB.NET中文双引号的处理方法
			
相信朋友们也都碰到了这样的问题了,VS的IDE会不分青红皂白的把中文双引号变成英文的双引号,当然可以通过关闭自动重排功能来回避这个问题,但不是一个好的解决办法,以下这个方式不错: 如果在实际的使用中我 ...
 - 简单的字符串压缩--C代码
			
#include <stdio.h> #include <string.h> bool compress(char *str) { char *p=str,c; ; if(!s ...
 - Dom4j  查找节点或属性
			
Dom4j 查找节点或属性 例如 1 查找下面xml中的student节点的age属性, xpathstr="/students/student/@age"; 2 查找下面xml ...
 - org.w3c.dom.Document 与org.dom4j.Document互转
			
public static Document parse(org.w3c.dom.Document doc) throws Exception { if (doc == null) { return ...
 - 威联通NAS 网站无法登录,可以ssh情况下重启设备方法
			
步骤: 1.VPN登录NAS 2.PUTTY SSH登录设备 3.reboot设备 等待重启约5分钟.