Sheldon Numbers GYM

题意:定义Sheldon Number为其二进制数是ABA……ABA型的或者ABAB……AB的,其中A全为1,B全为0(A>0, B>0),问[m, n]中有多少个Sheldon Number.

思路:只需要存储好所有A与B的情况,并枚举所有的ABA……ABA型的或者ABAB……AB的情况。

# include <bits/stdc++.h>
using namespace std; # define vi vector < int >
# define pb push_back
# define LL long long LL n, m;
string S[][];
set<LL > t; LL cal(string s){
LL sum = ;
for(int i = ; i < s.size(); i++){
sum *= ;
sum += s[i]-'';
}
return sum;
} LL solve(int a, int b){
string s;
LL k;
s += S[][a];
while(s.size()<=){
s += S[][b];
if(s.size() <=) {
k = cal(s);
if(k >= n && k <= m) {
t.insert(k);
// cout<<k<<" "<<s<<endl;
}
}
s += S[][a];
if(s.size() <=) {
k = cal(s);
if(k >= n && k <= m) {
t.insert(k);
// cout<<k<<" "<<s<<endl;
}
}
}
} void init(){
t.clear();
for(int i = ; i < ; i++){
for(int j = ; j < i; j++){
S[][i] += "";
S[][i] += "";
}
// cout<<S[0][i]<<" "<<S[1][i]<<endl;
} for(int i = ; i < ; i++){
for(int j = ; j < ; j++){
solve(i, j);
}
}
cout<<t.size();
} int main(void)
{
// freopen("input.txt", "r", stdin);
cin>>n>>m;
init();
return ;
}

Sheldon Numbers GYM -- 枚举的更多相关文章

  1. UVALive 7279 Sheldon Numbers (暴力打表)

    Sheldon Numbers 题目链接: http://acm.hust.edu.cn/vjudge/contest/127406#problem/H Description According t ...

  2. UVA - 13022 Sheldon Numbers(位运算)

    UVA - 13022 Sheldon Numbers 二进制形式满足ABA,ABAB数的个数(A为一定长度的1,B为一定长度的0). 其实就是寻找在二进制中满足所有的1串具有相同的长度,所有的0串也 ...

  3. 【枚举】Southwestern Europe Regional Contest H - Sheldon Numbers

    https://vjudge.net/contest/174235#problem/H [题意] 求[x,y]之间有多少个Sheldon Number Sheldon Number是二进制满足以下条件 ...

  4. Gym 101128F Sheldon Numbers(网络流)

    [题目链接] http://codeforces.com/gym/101128/attachments [题目大意] 给出一张地图,分为高地和低地,高低地的交界线上划有红线, 现在要开小车跨过每条红线 ...

  5. Gym - 101128H:Sheldon Numbers

    题意 给你两个整数X和Y 问你在区间[X,Y]中,有多少数字的二进制满足ABAB或者A这种形式.A是某个数量的1,B是某个数量的0. 分析 因为数据规模很大,直接枚举x和y之间的数字然后判断会超时.所 ...

  6. SOJ1029 Humble Numbers (枚举)

    A number whose only prime factors are 2,3,5 or 7 is called a humble number. The sequence 1, 2, 3, 4, ...

  7. Avito Cool Challenge 2018 E. Missing Numbers 【枚举】

    传送门:http://codeforces.com/contest/1081/problem/E E. Missing Numbers time limit per test 2 seconds me ...

  8. URAL 2031. Overturned Numbers (枚举)

    2031. Overturned Numbers Time limit: 1.0 second Memory limit: 64 MB Little Pierre was surfing the In ...

  9. HDU 1197 Specialized Four-Digit Numbers (枚举+进制转化,简单)

    题意:让求从2992-9999中所有数字,满足10进制各位之和和12进制和16进制各位数字之和相等. 析:没啥可说的,只能枚举从2992-9999,每个进制都算一下. 代码如下: #include & ...

随机推荐

  1. HEXO与Github.io搭建个人博客

    HEXO与Github.io搭建个人博客 HEXO搭建    HEXO是基于Node.JS的一款简单快速的博客框架,能够支持多线程,支持markdown,可以将生成的静态网页发布到github.io以 ...

  2. [转]FILE的用法

    #include <stdio.h> int main() { char c; ; FILE *file; file = fopen("test.txt", " ...

  3. zedboard学习记录.1.纯PL流水灯

    环境:vivado 217.4 开发板: zedboard ver.d xc7z020clg484-1 1.打开Vivado新建一个RTL工程. 2.add source->add/create ...

  4. perl6 struct2-045 EXP

    测试站点: http://www.yutian.com.cn/index.action http://www.hjxzyzz.com:8088/pfw/login.action 代码如下: use v ...

  5. sniffer简单使用

    跟wireshark类似. 只是说显示的容易忘记所以丢张图记录一下. 该工具还是很坑爹的,不是比赛要用到所以都不是很想弄.一般机器运行不起来.不是蓝屏就是装了运行不了各种闪退,找了学校一台内网服务器才 ...

  6. nginx之日志设置详解

    nginx的日志设置 access_log access_log是服务器记录了哪些用户,哪些页面以及用户浏览器.ip和其他的访问信息:是一种非常详细的记录信息:如果我们不关心谁访问了我们,可以关闭: ...

  7. Minimum Palindromic Factorization(最少回文串分割)

    Minimum Palindromic Factorization(最少回文串分割) 以下内容大部分(可以说除了关于回文树的部分)来自论文A Subquadratic Algorithm for Mi ...

  8. WPF之模拟打开或关闭Windows功能

    用WPF模拟打开或关闭Windows功能的实现方法其实很简单,主要用递归判断当前节点的子节点和父节点的选中状态就行了. 一.效果演示 先看看效果图: 二.部分代码 xaml代码: <TreeVi ...

  9. word2vec原理

    最原始的是NNLM,然后对其改进,有了后面的层次softmax和skip gram 层次softmax:去掉了隐藏层,后面加了huffuman树,concat的映射层也变成了sum skip gram ...

  10. 对cgic的理解——name选项

    #include <stdio.h>#include <stdlib.h>#include <string.h>#include "cgic.h" ...