预处理 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 ...
随机推荐
- 把字符串"3,1,2,4"以","分割拆分为数组,数组元素并按从小到大的顺序排列
package com.wangcf; /** * 把字符串"3,1,2,4"以","分割拆分为数组,数组元素并按从小到大的顺序排列 * @author fan ...
- 用P4对数据平面进行编程
引言 SDN架构强调了对控制平面的可编程,数据平面只负责转发,导致数据平面很大程度上受制于功能固定的包处理硬件. P4语言的特性: 目标无关性:P4语言不受制于具体设备,所有可编程芯片都可以使用P4编 ...
- 元素相加交换另解&puts的一个用法
#include<iostream> using namespace std; int main(){ int a,b; cin>>a>>b; a^=b; b^=a ...
- springMVC 流程
springMVC流程控制 SpringMVC流程 web.xml 中配置 org.springframework.web.servlet.DispatcherServlet 这一步其实和spring ...
- erlang节点互相ping,一个能ping通,另外一个不行。
今天发现一个问题,2个erlang节点,1个主动ping另外一个不通,然后等待另外一个ping过来,2个节点才连通.记录一下. 首先,erlang节点的cookie是一致的.查了文档,cookie一致 ...
- 解决Max retries exceeded with url的问题
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='itunes.apple.com', port=443): Max ret ...
- 操作系统cmd
实验一 命令解释程序的编写(两周内) 一.目的和要求 1. 实验目的 (1)掌握命令解释程序的原理: (2)*掌握简单的DOS调用方法: (3)掌握C语言编程初步. 2.实验要求 编写类似于DOS, ...
- bootstrap 中的静态模式的控制按钮上的一个坑
在使用modal时发现,代码:<button class="btn btn-danger" data-toggle="modal" data-target ...
- HDU4675_GCD of Sequence
很有意思的一个数论题. 是这样的,给你一个数数组a[i],其中给出的每一个数字和要求的数字方位都是[1,m],现在问你根据a[]构造一个b[],且a和b中间的不相等的元素的个数恰好有k个. 现在问你g ...
- BZOJ4972 小Q的方格纸
每个格子记录其左下的45°直角梯形区域的和及左下矩形区域的和即可. #include<iostream> #include<cstdio> #include<cmath& ...