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 ...
随机推荐
- dubbo+zookeeper搭建笔记
参考博客: http://blog.csdn.net/u013142781/article/details/50396621#reply http://blog.csdn.net/u013142781 ...
- Mac电脑怎么远程桌面连接
https://jingyan.baidu.com/article/e75aca85039448142fdac651.html https://blog.csdn.net/youshaoduo/art ...
- 使用jps查看JVM进程信息
VM进程状态工具 - 列出目标系统上已检测的HotSpot Java虚拟机进程信息.可直接在装有java运行环境的Windows 或者 Linux机器上使用命令行执行jps命令.一个典型的应用场景,例 ...
- wordpress 修改默认分页条数
哎,终于快做完了,今天弄了弄分页,真是网上扒的模板太高级了,把分页和导航的css和js冲突了,终于解决了, 然后有一个模板是三和一排显示的,其他的是单挑显示的,它默认10条,我寻思改成9条,找了半天, ...
- java.lang.String和java.util.NClob互相转换
//NClob或Clob转String类型 public String clob2Str(NClob nclob) throws Exception { String content = " ...
- SpringBoot-自动装载
1,SpringBoot里面有内置的tomcat容器. 2,SpringBoot是基于已有的东西创建的新的东西.核心:(AutoConfiguration)自动装载,Starter,Actuator, ...
- java NIO - DirectBuffer 和 HeapBuffer
问题 : DirectBuffer 属于堆外存,那应该还是属于用户内存,而不是内核内存? FileChannel 的read(ByteBuffer dst)函数,write(ByteBuffer sr ...
- MySQL基本查询
1.查询某数据库中表的总数 select count(*) from information_schema.tables where table_schema='dbname'; 2.仅占一列显示某数 ...
- How to Start Learning Computer Graphics
Background Input\Output Image Knowledge Image Digital Image Processing Computer Vision Knowledge Com ...
- VMwarePro密钥
VMware10Pro密钥 5F29M-48312-8ZDF9-A8A5K-2AM0Z VMware12Pro密钥 5A02H-AU243-TZJ49-GTC7K-3C61N VF5XA-FNDDJ- ...