预处理 Gym - 101128H
题目链接:http://codeforces.com/gym/101128
题目大意:给你一个区间[x,y],找出这个区间有多少个seldom的数字。
seldom的数字定义如下:该数值的二进制数字符合如下条件ABAB...ABAB 或者 ABABA....BA,其中A表示连续的1的个数,B表示连续的0的个数。
思路:因为长度只有63,本来以为是数位dp的,想了想直接暴力预处理就好了
//看看会不会爆int!数组会不会少了一维!
//取物问题一定要小心先手胜利的条件
#include <bits/stdc++.h>
using namespace std;
#pragma comment(linker,"/STACK:102400000,102400000")
#define LL long long
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define haha printf("haha\n")
LL x, y;
vector<LL> ve; void solve(LL tmp, LL tmp1, LL i, LL j, int len){
int cnt = ;
while (true){
if (cnt % == ){
cnt++;
if (len + i > ) break;
len += i;
tmp = tmp << i; tmp += tmp1;
ve.pb(tmp);
}
else {
cnt++;
if (len + j > ) break;
len += j;
tmp = tmp << j;
ve.pb(tmp);
}
//printf("tmp = %lld\n", tmp);
}
} void init(){
for (int i = ; i <= ; i++){///这个是1的东西
LL tmp1 = ;
for (int f = ; f < i; f++){
tmp1 |= (1LL << f);
}
ve.pb(tmp1);
for (int j = ; j <= ; j++){///这个是0的东西
if (i + j > ) break;
LL tmp = tmp1 << j;
ve.pb(tmp);
solve(tmp, tmp1, i, j, i + j);
}
}
sort(ALL(ve));
} int main(){
init();
while (scanf("%lld%lld", &x, &y) == ){
int lb = lower_bound(ve.begin(), ve.end(), x) - ve.begin();
int rb = upper_bound(ve.begin(), ve.end(), y) - ve.begin();
printf("%d\n", rb - lb);
}
return ;
}
预处理 Gym - 101128H的更多相关文章
- Gym - 101128H:Sheldon Numbers
题意 给你两个整数X和Y 问你在区间[X,Y]中,有多少数字的二进制满足ABAB或者A这种形式.A是某个数量的1,B是某个数量的0. 分析 因为数据规模很大,直接枚举x和y之间的数字然后判断会超时.所 ...
- Gym 100952H&&2015 HIAST Collegiate Programming Contest H. Special Palindrome【dp预处理+矩阵快速幂/打表解法】
H. Special Palindrome time limit per test:1 second memory limit per test:64 megabytes input:standard ...
- Gym 100952D&&2015 HIAST Collegiate Programming Contest D. Time to go back【杨辉三角预处理,组合数,dp】
D. Time to go back time limit per test:1 second memory limit per test:256 megabytes input:standard i ...
- Codeforces Gym 101194C Mr. Panda and Strips(2016 EC-Final,区间DP预处理 + 枚举剪枝)
题目链接 2016 EC-Final 题意 现在要找到数列中连续两个子序列(没有公共部分).要求这两个子序列本身内部没有重复出现的数. 求这两个子序列的长度的和的最大值. 首先预处理一下.令$ ...
- GYM 101673E(暴搜预处理)
1.不会超过500个不同的串-- 2.样例没给has到has是怎么样的,实测是true. 3.记忆化别剪错枝就好,嘤嘤嘤-- const int maxn = 505 + 5; int n, m, t ...
- Codeforces Gym 100231L Intervals 数位DP
Intervals 题目连接: http://codeforces.com/gym/100231/attachments Description Start with an integer, N0, ...
- Codeforces Gym 100342J Problem J. Triatrip bitset 求三元环的数量
Problem J. TriatripTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100342/att ...
- 【模拟】NEERC15 A Adjustment Office (2015-2016 ACM-ICPC)(Codeforces GYM 100851)
题目链接: http://codeforces.com/gym/100851 题目大意: 一个N*N的矩阵A,Ai,j=i+j,Q次操作,每次分两种,R r取出第r行还未被取的所有数,并输出和.C c ...
- Gym - 101982B Coprime Integers (莫比乌斯反演)
题目链接:http://codeforces.com/gym/101982/attachments 题目大意:有区间[a,b]和区间[c,d],求gcd(x,y)=1,其中x属于[a,b],y属于[c ...
随机推荐
- Beta阶段第一次网络会议
Beta阶段第一次网络会议 游戏问题 游戏细节特征不够明显,大小虽然随着电脑分辨率的不同变化着,但是存在清楚的问题 游戏中的提示信息不够,玩家无法快速了解游戏 游戏中背景声音过于单一 游戏AI太简单 ...
- java 数据库查询Date类型字段 没有了时分秒 全为 00 的解决办法
当取出这个值的时候只能用java.sql.Date而且只能显示年月日,我想知道如何才能显示时分秒 PS:不改变用getdate()存入的前提下! 解决方法:将getDate()方法改为getTim ...
- 严重: Failed to destroy end point associated with ProtocolHandler ["http-nio-8080"] java.lang.NullPointer
刚接触servlet类,按照课本的方法使用eclipse新建了一个servlet类. 新建完成后,在web.xml里面进行注册 这时候就会报错了. 五月 07, 2016 11:23:28 上午 or ...
- lintcode-206-区间求和 I
206-区间求和 I 给定一个整数数组(下标由 0 到 n-1,其中 n 表示数组的规模),以及一个查询列表.每一个查询列表有两个整数 [start, end] . 对于每个查询,计算出数组中从下标 ...
- C++ Primer Plus学习:第十章
过程性编程和面向对象编程 面向对象编程(OOP)的特性: 抽象 封装和数据隐藏 多态 继承 代码的可重用性 抽象和类 类是一种将抽象转化为用户定义类型的C++工具,它将数据表示和操纵数据的方法合成一个 ...
- erlang驱动使用mysql-otp
Magnus Ahltorp的Mysql Driver里面介绍emysql的缺陷: 1. 隔离不够好, 2.不能伸缩 mysql-otp使用1个进程1个mysql连接,隔离得很好.推荐使用. mysq ...
- 蜗牛慢慢爬 LeetCode 8. String to Integer (atoi) [Difficulty: Medium]
题目 Implement atoi to convert a string to an integer. Hint: Carefully consider all possible input cas ...
- 【转】Linux C 网络编程——TCP套接口编程
地址:http://blog.csdn.net/matrix_laboratory/article/details/13669211 2. socket() <span style=" ...
- c#中,字符串前加@是什么意思
让转移字符"\"保持原意,不要转义,如一个地址字符串string path="c:\abc\";默认的"\"是作为转义来使用的,而不是一个真 ...
- 第188天:extend拷贝创建对象的原理
一.拷贝创建对象的原理 //拷贝创建对象核心代码 function extend(target,source) { //遍历对象 for(var i in source){ target[i] = s ...