题意:

统计间隔在1中0的个数

思路:

超简单写法,直接利用string的find、rfind函数即可

#include<bits/stdc++.h>
using namespace std;
int main() {
//freopen("in.txt", "r", stdin);
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
int t; cin >> t;
while (t--) {
string s; cin >> s;
int cnt = 0;
int first = s.find('1');
int last = s.rfind('1');
for (int i = first; i < last; i++) if (s[i] == '0')cnt++;
cout << cnt << endl;
}
}

Educational Codeforces Round 82 (Rated for Div. 2) A. Erasing Zeroes(超简单的写法)的更多相关文章

  1. Educational Codeforces Round 82 (Rated for Div. 2)

    题外话 开始没看懂D题意跳了,发现F题难写又跳回来了.. 语文好差,码力好差 A 判第一个\(1\)跟最后一个\(1\)中\(0\)的个数即可 B 乘乘除除就完事了 C 用并查集判一下联通,每个联通块 ...

  2. Educational Codeforces Round 82 (Rated for Div. 2) A-E代码(暂无记录题解)

    A. Erasing Zeroes (模拟) #include<bits/stdc++.h> using namespace std; typedef long long ll; ; in ...

  3. Educational Codeforces Round 82 (Rated for Div. 2)E(DP,序列自动机)

    #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ],t[]; int n,m; ][]; ...

  4. Educational Codeforces Round 82 (Rated for Div. 2)D(模拟)

    从低位到高位枚举,当前位没有就去高位找到有的将其一步步拆分,当前位多余的合并到更高一位 #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h&g ...

  5. [CF百场计划]#3 Educational Codeforces Round 82 (Rated for Div. 2)

    A. Erasing Zeroes Description You are given a string \(s\). Each character is either 0 or 1. You wan ...

  6. Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - C. Magic Ship Time Limit: 2000 mSec P ...

  7. Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems(动态规划+矩阵快速幂)

    Problem   Educational Codeforces Round 60 (Rated for Div. 2) - D. Magic Gems Time Limit: 3000 mSec P ...

  8. Educational Codeforces Round 43 (Rated for Div. 2)

    Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...

  9. Educational Codeforces Round 35 (Rated for Div. 2)

    Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...

  10. Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings

    Codeforces Educational Codeforces Round 44 (Rated for Div. 2) F. Isomorphic Strings 题目连接: http://cod ...

随机推荐

  1. 神经网络入门篇:详解随机初始化(Random+Initialization)

    当训练神经网络时,权重随机初始化是很重要的.对于逻辑回归,把权重初始化为0当然也是可以的.但是对于一个神经网络,如果把权重或者参数都初始化为0,那么梯度下降将不会起作用. 来看看这是为什么. 有两个输 ...

  2. 飞腾E2000板载以太网适配

    飞腾E2000板载以太网适配 e20005.4.18macbyt8521 1. 设备树移植 2. MACB驱动移植 3. 网络连通性调试 3-1. MACB驱动环回测试 3-2. YT8521 PHY ...

  3. 【Spring Boot】【外包杯】学习day01 | 项目目录结构划分以及代码分层

    起因:扒了一个开源的项目,但是啃起来很硬,所以决定开始学习相关的知识. 我们之前的SSM项目,搭建过程较为繁琐: 1)配置 web.xml,加载 spring 和 spring mvc 2)配置数据库 ...

  4. 老是听到做PPT要会“内容可视化”,到底啥是内容可视化?

    在PPT中,内容可视化是指将文字.数据和概念等抽象信息转化为图像.图表.图表及其他可视化元素来呈现.通过合适的颜色.形状.大小和布局等视觉设计元素来强调信息的关键点和关系, 从而提高观众对信息的理解和 ...

  5. 神经网络优化篇:详解偏差,方差(Bias /Variance)

    偏差,方差 注意到,几乎所有机器学习从业人员都期望深刻理解偏差和方差,这两个概念易学难精,即使自己认为已经理解了偏差和方差的基本概念,却总有一些意想不到的新东西出现.关于深度学习的误差问题,另一个趋势 ...

  6. Socket.D 网络应用协议,v2.1.6 发布

    有用户说,"Socket.D 之于 Socket,尤如 Vue 之于 Js.Mvc 之于 Http" 与其它协议的简单对比 对比项目 socket.d http websocket ...

  7. vue-test -------style绑定

    <template> <p :style="{color:activeColor,fontSize:fontsize+'px'}"></p> & ...

  8. NC65单据模板公式使用

    单据模板公式使用 (一) 公式使用场景 用户使用产品时,往往对单据上的字段取值有各种不同的需求.为此单据模板提供 了模板公式功能,可以让实施顾问或者用户通过配置各种公式,并且不用修改代码,从 而满足用 ...

  9. ngnix学习-反向代理

    代理:可以理解为中间商,用来帮助事物A和事物B建立连接的桥梁. 什么是反向代理呢,其实就是反过来,反客为主大家都知道吧. 说明: 这里稍微罗嗦一下.做一个说明. 正常情况下,你是需要干什么,才去干什么 ...

  10. st_geometry、st_transform配置及问题汇总

    1.文件配置修改 路径上一定要使用双斜杠 2.使用sde账号登录,执行以下SQL,路径按照实际环境填写. select * from user_libraries; create or replace ...