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 ...
随机推荐
- LeetCode | No.2 两数相加
题目描述 给出两个非空的链表用来表示两个非负的整数.其中,它们各自的位数是按照 逆序的方式存储的,并且它们的每个节点只能存储一位数字.如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和 ...
- web前端技能考核(阿里巴巴)
- HDU1276-士兵队列训练问题 (Queue)
题很简单,STL中queue的基本使用. #include <bits/stdc++.h> using namespace std; int N,num; int main() { sca ...
- 在 Fabric 中使用私有数据
本教程将演示收集器(collection)的使用,收集器为区块链网络上已授权的组织节点 提供私有数据的存储和检索. 本教程假设您已了解私有数据的存储和他们的用例.更多的信息请参阅 私有数据 . 本教程 ...
- C语言:计算输出给定数组中每相邻两个元素的平均值的平方根之和。
//计算输出给定数组中每相邻两个元素的平均值的平方根之和. #include <stdio.h> #include <math.h> ]) { double a,b,s=0.0 ...
- 使用 swiper 制作 导航,点击项居中
目的:导航有多个,被点击的项居中显示. html: <div class="swiper-container"> <div class="swiper- ...
- c#本地缓存当数据库表更改时,缓存失效。
web.config <?xml version="1.0" encoding="utf-8"?> <!-- 有关如何配置 ASP.NET 应 ...
- UIViewController的API
- (instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil; 返回一个新初始化 ...
- 翻页插件 jquery
//css <style> * { padding:; margin:; list-style: none; } .wrapper { width: 100%; cursor: point ...
- 解决前端项目启动时报错:Use // eslint-disable-next-line to ignore the next line.
首先说一下这个问题产生的原因: 项目创建时设置了使用 eslint 进行代码规范检查. 解决办法: 找到webpack.base.conf.js文件,并且将下满这行代码注释掉. ...(config. ...