题目链接:点击打开链接

#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(水的更多相关文章

  1. poj1564 Sum It Up dfs水题

    题目描述: Description Given a specified total t and a list of n integers, find all distinct sums using n ...

  2. Openjudge1388 Lake Counting【DFS/Flood Fill】

    http://blog.csdn.net/c20182030/article/details/52327948 1388:Lake Counting 总时间限制:   1000ms   内存限制:  ...

  3. POJ2386 Lake Counting 【DFS】

    Lake Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20782   Accepted: 10473 D ...

  4. POJ_2386 Lake Counting (dfs 错了一个负号找了一上午)

    来之不易的2017第一发ac http://poj.org/problem?id=2386 Lake Counting Time Limit: 1000MS   Memory Limit: 65536 ...

  5. hdu 3887 Counting Offspring dfs序+树状数组

    Counting Offspring Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Othe ...

  6. 【wikioi】1229 数字游戏(dfs+水题)

    http://wikioi.com/problem/1229/ 赤裸裸的水题啊. 一开始我认为不用用完全部的牌,以为爆搜会tle.. 可是我想多了. 将所有状态全部求出,排序后暴力判断即可. (水题有 ...

  7. HDU 2952 Counting Sheep(DFS)

    题目链接 Problem Description A while ago I had trouble sleeping. I used to lie awake, staring at the cei ...

  8. Oil Deposits(dfs水)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1241 Oil Deposits Time Limit: 2000/1000 MS (Java/Othe ...

  9. Poj2386 Lake Counting (DFS)

    Lake Counting Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 49414   Accepted: 24273 D ...

随机推荐

  1. Java web application——基础

    概述 一个WAR文件包含了构成一个Web应用程序所需要的文件.WAR文件作为一个单元部署在一个或多个WebLogic Server实例上. WebLogic Server上的Web存档始终包含以下文件 ...

  2. Linux 下安装 redis 详情

    一:将redis 压缩包上传到 Linux  usr/local下 (一):在local 下创建一个 redis 目录 (二):上传redis压缩包到此目录下. 二:Linux 进入 local目录下 ...

  3. Spring学习总结(12)——Druid连接池及监控在spring配置

    Druid连接池及监控在spring配置如下: <bean id="dataSource" class="com.alibaba.druid.pool.DruidD ...

  4. Java基础学习总结(18)——网络编程

    一.网络基础概念 首先理清一个概念:网络编程 != 网站编程,网络编程现在一般称为TCP/IP编程. 二.网络通信协议及接口 三.通信协议分层思想 四.参考模型 五.IP协议 每个人的电脑都有一个独一 ...

  5. codevs——T2806 红与黑

    http://codevs.cn/problem/2806/  时间限制: 1 s  空间限制: 64000 KB  题目等级 : 白银 Silver 题解       题目描述 Descriptio ...

  6. spring的PropertyPlaceholderConfigurer不生效的问题

    经常出现这种问题,每次都debug知道原因,但每次都会忘记,所以记录一下. 原因:maven项目中使用了非maven管理的jar包(通过systemPath引用),这些jar包没有放在${projec ...

  7. CODE ---代码助手 (保存代码、搜代码、生成网页、自由界面)

    四大功能 1  保存代码 2  搜索代码 3  生成网页 4  自由界面 www.gudianxiaoshuo.com

  8. vue18 动画

    <!-- bower-> (前端)包管理器 npm install bower -g 验证: bower --version bower install <包名> bower ...

  9. IIS Modules Overview

    Introduction The IIS 7 and above Web server feature set is componentized into more than thirty indep ...

  10. 洛谷P2633 Count on a tree

    题目描述 给定一棵N个节点的树,每个点有一个权值,对于M个询问(u,v,k),你需要回答u xor lastans和v这两个节点间第K小的点权.其中lastans是上一个询问的答案,初始为0,即第一个 ...