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 ...
随机推荐
- pwnable.kr-random-Writeup
MarkdownPad Document *:first-child { margin-top: 0 !important; } body>*:last-child { margin-botto ...
- IIS-7.5 第一次加载慢的 解决办法
问题焦点 Win2008R2,Win7 下面IIS部署的.NET站点第一次加载比较慢. 解决办法: 1.基本原理: 在第一个请求到达之前加载Web应用程序,从而提高其网站的响应性.通过主动加载和初始化 ...
- liux 命令行
查找文件 () find / -name httpd.conf #在根目录下查找文件httpd.conf,表示在整个硬盘查找 () find /etc -name httpd.conf #在/etc目 ...
- 最新版的 vscode 怎么配置 Python?
请进 -- > https://www.zhihu.com/question/322530705/answer/860418884
- 吴裕雄--天生自然神经网络与深度学习实战Python+Keras+TensorFlow:使用TensorFlow和Keras开发高级自然语言处理系统——LSTM网络原理以及使用LSTM实现人机问答系统
!mkdir '/content/gdrive/My Drive/conversation' ''' 将文本句子分解成单词,并构建词库 ''' path = '/content/gdrive/My D ...
- php中判断shell_exec执行结果
$shell = "wget -O despath sourcepath && echo 'success' "; $shellExec = shell_exec( ...
- Vue项目中sass语法该怎么用?
最近开始着手Vue框架,被各种报错蹂躏,其中有一个就是sass语法,<style>标签中添加<style lang="scss">,发现报错,在网上找了一些 ...
- 微信小程序开发豆瓣电影接口失效
豆瓣旧API接口停用,使用以下接口代替 .获取正在热映的电影:https://douban.uieee.com/v2/movie/in_theaters访问参数:start : 数据的开始项 coun ...
- call深入理解
function fn1() { console.log(1); } function fn2() { console.log(2); } fn1.call(fn2); // 1 fn1.call.c ...
- CSS-自适应网页使用@media和rem
@media 查询 @media 媒体查询选择性加载css,意思是自动探测屏幕宽度,然后加载相应的CSS文件.可以针对不同的屏幕尺寸设置不同的样式,特别是需要设置设计响应式的页面,@media 是个不 ...