Educational Codeforces Round 72 (Rated for Div. 2)C(暴力)
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
char s[200007];
int a[200007][20];
int main(){
int t;
cin>>t;
while(t--){
cin>>s+1;
int n=strlen(s+1);
for(int i=0;i<=n;++i)
for(int j=0;j<=18;++j)
a[i][j]=0;
for(int i=1;i<=n;++i){
if(s[i]=='1'){
a[i][1]=1;
for(int j=2;j<=18;++j){
if(i+j-1>n)
break;
a[i][j]=a[i][j-1]<<1;//i为起点,i+j为终点
if(s[i+j-1]=='1')//i+j-1即前最后一位,该位为1,+1即可
a[i][j]++;
}
}
}
int x=1;//离i最近的不为0的位置
int ans=0;
int tmp=0;
for(int i=1;i<=n;++i){
if(s[i]=='1'){
tmp=i-x;//前导零的个数
for(int j=1;j<=18;++j){
if(i+j-1>n)
break;
if(tmp+j>=a[i][j])//如果a[i][j]<=前导零的个数加上j(i~i+j,第i位为1),那么去掉一些前导零,即可a[i][j]==j+前导零的个数
++ans;
}
x=i+1;
}
}
cout<<ans<<"\n";
}
return 0;
}
Educational Codeforces Round 72 (Rated for Div. 2)C(暴力)的更多相关文章
- Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序
Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序 [Problem Description] 给你 ...
- 拓扑排序入门详解&&Educational Codeforces Round 72 (Rated for Div. 2)-----D
https://codeforces.com/contest/1217 D:给定一个有向图,给图染色,使图中的环不只由一种颜色构成,输出每一条边的颜色 不成环的边全部用1染色 ps:最后输出需要注意, ...
- Educational Codeforces Round 72 (Rated for Div. 2)
https://www.cnblogs.com/31415926535x/p/11601964.html 这场只做了前四道,,感觉学到的东西也很多,,最后两道数据结构的题没有补... A. Creat ...
- Educational Codeforces Round 72 (Rated for Div. 2) C题
C. The Number Of Good Substrings Problem Description: You are given a binary string s (recall that a ...
- Educational Codeforces Round 72 (Rated for Div. 2) B题
Problem Description: You are fighting with Zmei Gorynich — a ferocious monster from Slavic myths, a ...
- Educational Codeforces Round 72 (Rated for Div. 2) A题
Problem Description: You play your favourite game yet another time. You chose the character you didn ...
- Coloring Edges(有向图环染色)-- Educational Codeforces Round 72 (Rated for Div. 2)
题意:https://codeforc.es/contest/1217/problem/D 给你一个有向图,要求一个循环里不能有相同颜色的边,问你最小要几种颜色染色,怎么染色? 思路: 如果没有环,那 ...
- Educational Codeforces Round 72 (Rated for Div. 2) Solution
传送门 A. Creating a Character 设读入的数据分别为 $a,b,c$ 对于一种合法的分配,设分了 $x$ 给 $a$ 那么有 $a+x>b+(c-x)$,整理得到 $x&g ...
- Educational Codeforces Round 72 (Rated for Div. 2)E(线段树,思维)
#define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;#define BUF_SIZE 100000 ...
随机推荐
- C语言创建共享库(动态库)步骤
C语言创建共享库(动态库)步骤: 创建sth.c,共享库源文件: //sth.c库源程序 unsigned long long sth(unsigned int x, unsigned int y) ...
- Java日期时间API系列21-----Jdk8中java.time包中的新的日期时间API类,xk-time时间转换,计算,格式化,解析的工具
通过工作之余,对Java8中java.time包源码的不断学习,使用和总结,开发了xk-time,初步完成,欢迎试用和提出建议! xk-time xk-time is a datetime conve ...
- 8.5-Day1T1--Asm.Def 谈笑风生
题目大意 m个操作, 1:添加一个字符串 2:查询字符串s是否被添加过(中至多包含一个通配符“*”) 题解 trie树可以得部分分 用map映射 '*'就枚举26个英文字母来判断就可以了 #inclu ...
- GitBook的账号注册和安装使用(一)
1.GitBook账号注册 GitBook原注册地址 https://legacy.gitbook.com/join 改为: https://www.gitbook.com/ (1)注册账号:htt ...
- 一周搞定模拟电路P2_二极管介绍_记录
1 稳压二极管 1.1 稳压二极管伏安特性曲线 ΔIz 这一段为能够达到比较好的稳压效果的稳压电流. 1.2 两种连接方法的比较 2 整流二极管 2.1 特点 用于把交流电变成脉动直流电 3 开关二极 ...
- netty(二)---客户端连接
概述 先了解一下 netty 大概框架图 ,可以看到客户端的创建和服务端最大的区别 - 服务端传入两个 EventLoopGroup,客户端传入一个 EventLoopGroup - channel ...
- 【CSS属性#1】
" 目录 一.宽和高 二.字体属性 1. 文字字体 font-famlly 2. 字体大小 font-size 3. 字重(粗细) font-weight 4. 文本颜色 color 三.字 ...
- 【MySQL】存储引擎
" 目录 #. MySQL支持的存储引擎 1. InnoDB 2. MyISAM 3. NDB 4. Memory 5. Infobright 6. NTSE 7. BLACKHOLE My ...
- springboot学习4使用日志:logback
springboot学习4使用日志:logback 一.基本知识说明 SpringBoot默认使用logback作为日志框架 ,所以引入起步依赖后就可以直接使用logback,不需要其他依赖. Spr ...
- LNMP环境搭建(PHP7.4.0)
目录 准备工作 安装wget 安装net-tools 安装vim 配置显示行号 关闭防火墙 安装Nginx 安装依赖 编译安装Nginx 配置环境变量 Systemd管理 安装MySQL 安装依赖 下 ...