D - A or...or B Problem
题意:给定A,B,问[A,B]里取任意个数按位或,结果有多少种。
思路:这题需要找出一个分界点,即找到最高位的B是1,A是0的位置x(最低位从0开始),那么对于所有OR的结果,x处要么是1要么是0,x是0有多少种呢?这里就需要从[A,1<<x)里挑选数进行OR,即有(1<<x)-A种,因为A到(1<<x)-1都可以表示出来;x处为1有几种呢?有两种情况①从(1<<x, B]里挑选,结果就不说了依此类推,②从上述两个区间都挑选,那就是也是(1<<x)-A种,然后上述两种两种情况可能会有重复,需要判断去重,最后判读是否要加上(1<<x)这一种就行了
D - A or...or B Problem的更多相关文章
- 1199 Problem B: 大小关系
求有限集传递闭包的 Floyd Warshall 算法(矩阵实现) 其实就三重循环.zzuoj 1199 题 链接 http://acm.zzu.edu.cn:8000/problem.php?id= ...
- No-args constructor for class X does not exist. Register an InstanceCreator with Gson for this type to fix this problem.
Gson解析JSON字符串时出现了下面的错误: No-args constructor for class X does not exist. Register an InstanceCreator ...
- C - NP-Hard Problem(二分图判定-染色法)
C - NP-Hard Problem Crawling in process... Crawling failed Time Limit:2000MS Memory Limit:262144 ...
- Time Consume Problem
I joined the NodeJS online Course three weeks ago, but now I'm late about 2 weeks. I pay the codesch ...
- Programming Contest Problem Types
Programming Contest Problem Types Hal Burch conducted an analysis over spring break of 1999 and ...
- hdu1032 Train Problem II (卡特兰数)
题意: 给你一个数n,表示有n辆火车,编号从1到n,入站,问你有多少种出站的可能. (题于文末) 知识点: ps:百度百科的卡特兰数讲的不错,注意看其参考的博客. 卡特兰数(Catalan):前 ...
- BZOJ2301: [HAOI2011]Problem b[莫比乌斯反演 容斥原理]【学习笔记】
2301: [HAOI2011]Problem b Time Limit: 50 Sec Memory Limit: 256 MBSubmit: 4032 Solved: 1817[Submit] ...
- [LeetCode] Water and Jug Problem 水罐问题
You are given two jugs with capacities x and y litres. There is an infinite amount of water supply a ...
- [LeetCode] The Skyline Problem 天际线问题
A city's skyline is the outer contour of the silhouette formed by all the buildings in that city whe ...
- PHP curl报错“Problem (2) in the Chunked-Encoded data”解决方案
$s = curl_init(); curl_setopt($s, CURLOPT_POST, true); curl_setopt($s, CURLOPT_POSTFIELDS, $queryStr ...
随机推荐
- ASP.NET Core 入门笔记8,ASP.NET Core MVC 分部视图入门
一.前言 1.本教程主要内容 ASP.NET Core MVC (Razor)分部视图简介 ASP.NET Core MVC (Razor)分部视图基础教程 ASP.NET Core MVC (Raz ...
- button与subit区别
submit介绍 submit是button的一个特例,也是button的一种,它把提交这个动作自动集成了.如果表单在点击提交按钮后需要用JS进行处理(包括输入验证)后再提交的话,通常都必须把su ...
- C学习笔记-第一个C语言程序
第一个C语言程序 #include<stdio.h> //1 int main() //2 { printf("This is a C language"); //3 ...
- mysql数据库之事务与存储过程
事务 什么是事务? 事务是指一些SQL语句的集合,这些语句同时执行成功完成某项功能 事务的CAID特性: 原子性:一个事务的执行是整体性的,要么内部所有语句都执行成功,要么一个都别想成功 一致性:事务 ...
- Nginx 配置文件解释及简单配置
Nginx配置文件大致分为以下几个块 1.全局块:配置影响nginx全局的指令.一般有运行nginx服务器的用户组,nginx进程pid存放路径,日志存放路径,配置文件引入,允许生成worker pr ...
- 暑假--升级攻击家庭wifi
参考: 1.http://blog.jobbole.com/64832/ 2.http://blog.jobbole.com/65851/ 3.http://blog.jobbole.com/6562 ...
- ZooKeeper的安装及部署
Zookeeper的安装部署 2.1 Zookeeper的安装 Zookeeper安装前需要安装好 JDK.配置好环境变量. 下载:zookeeper-3.4.5-cdh5.7.0.tar.gz 解压 ...
- Oracle如何创建索引、删除索引、查询索引
1.创建单一索引 create index 索引名称 on 表名(列名); 2.创建复合索引 create index 索引名称 on 表名(列名1,列名2); 3.删除索引 drop index 索 ...
- 烯烃(olefin) 题解
题面 对于每个点,我们可以用一次dfs求出这个点到以这个点为字树的最远距离和次远距离: 然后用换根法再来一遍dfs求出这个点到除这个点子树之外的最远距离: 显然的,每次的询问我们可以用向上的最大值加向 ...
- H. The Nth Item(The 2019 Asia Nanchang First Round Online Programming Contest)
题意:https://nanti.jisuanke.com/t/41355 给出N1,计算公式:A=F(N)Ni=Ni-1 ^ (A*A),F为类斐波那契需要矩阵快速幂的递推式. 求第k个N. 思路: ...