#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(暴力)的更多相关文章

  1. Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序

    Educational Codeforces Round 72 (Rated for Div. 2)-D. Coloring Edges-拓扑排序 [Problem Description] ​ 给你 ...

  2. 拓扑排序入门详解&&Educational Codeforces Round 72 (Rated for Div. 2)-----D

    https://codeforces.com/contest/1217 D:给定一个有向图,给图染色,使图中的环不只由一种颜色构成,输出每一条边的颜色 不成环的边全部用1染色 ps:最后输出需要注意, ...

  3. Educational Codeforces Round 72 (Rated for Div. 2)

    https://www.cnblogs.com/31415926535x/p/11601964.html 这场只做了前四道,,感觉学到的东西也很多,,最后两道数据结构的题没有补... A. Creat ...

  4. 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 ...

  5. Educational Codeforces Round 72 (Rated for Div. 2) B题

    Problem Description: You are fighting with Zmei Gorynich — a ferocious monster from Slavic myths, a ...

  6. 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 ...

  7. Coloring Edges(有向图环染色)-- Educational Codeforces Round 72 (Rated for Div. 2)

    题意:https://codeforc.es/contest/1217/problem/D 给你一个有向图,要求一个循环里不能有相同颜色的边,问你最小要几种颜色染色,怎么染色? 思路: 如果没有环,那 ...

  8. 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 ...

  9. Educational Codeforces Round 72 (Rated for Div. 2)E(线段树,思维)

    #define HAVE_STRUCT_TIMESPEC#include<bits/stdc++.h>using namespace std;#define BUF_SIZE 100000 ...

随机推荐

  1. css 溢出滚动条显示,修改滚动条样式

    文本或者内容溢出滚动条显示: a/横纵都出滚动条:css添加属性{overflow:auto;} b/横向滚动条:css添加属性{overflow-x:auto;} c/纵向滚动条:css添加属性{o ...

  2. Django objects.all()、objects.get()与objects.filter()之间的区别介绍

    前言 本文主要介绍的是关于Django objects.all().objects.get()与objects.filter()直接区别的相关内容,文中介绍的非常详细,需要的朋友们下面来一起看看详细的 ...

  3. Django+Celery+redis kombu.exceptions.EncodeError:Object of type is not JSON serializable报错

    在本文中例子中遇到问题的各种开发版本如下: Python3.6.8 Django==2.2 celery==4.4.0 kombu==4.6.7 redis==3.3.0 大概的报错如下截图: 是在开 ...

  4. SQL中AVG、COUNT、SUM、MAX等聚合函数对NULL值的处理

    一.AVG() 求平均值注意AVE()忽略NULL值,而不是将其作为“0”参与计算 二.COUNT() 两种用法 1.COUNT(*) 对表中行数进行计数不管是否有NULL 2.COUNT(字段名) ...

  5. 多个python版本共存时,查看pip命令属于哪个python的命令

    使用命令: pip -V 或 pip3 -V

  6. C语言:输入一个数,输出比这个数小的所有素数,并求出个数。

    //C语言:输入一个数,输出比这个数小的所有素数,并求出个数. #include<conio.h> #include<stdio.h> #include<stdlib.h ...

  7. Spark性能调优-基础篇

    前言 在大数据计算领域,Spark已经成为了越来越流行.越来越受欢迎的计算平台之一.Spark的功能涵盖了大数据领域的离线批处理.SQL类处理.流式/实时计算.机器学习.图计算等各种不同类型的计算操作 ...

  8. python opencv:保存图像

  9. Many Formulas

    You are given a string S consisting of digits between 1 and 9, inclusive. You can insert the letter ...

  10. redis基本操作,基于StringRedisTemplate,存储,取值,设置超时时间,获取超时时间,插入list操作

    @Autowired private StringRedisTemplate stringRedisTemplate; @GetMapping("/test") void test ...