Educational Codeforces Round 82 (Rated for Div. 2) A. Erasing Zeroes(超简单的写法)

题意:
统计间隔在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(超简单的写法)的更多相关文章
- Educational Codeforces Round 82 (Rated for Div. 2)
题外话 开始没看懂D题意跳了,发现F题难写又跳回来了.. 语文好差,码力好差 A 判第一个\(1\)跟最后一个\(1\)中\(0\)的个数即可 B 乘乘除除就完事了 C 用并查集判一下联通,每个联通块 ...
- 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 ...
- 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; ][]; ...
- Educational Codeforces Round 82 (Rated for Div. 2)D(模拟)
从低位到高位枚举,当前位没有就去高位找到有的将其一步步拆分,当前位多余的合并到更高一位 #define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h&g ...
- [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 ...
- 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 ...
- 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 ...
- Educational Codeforces Round 43 (Rated for Div. 2)
Educational Codeforces Round 43 (Rated for Div. 2) https://codeforces.com/contest/976 A #include< ...
- Educational Codeforces Round 35 (Rated for Div. 2)
Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...
- 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 ...
随机推荐
- Flutter搭建
目录 下载 Flutter SDK 配置 Flutter 环境变量及镜像 检查开发环境 参考 下载 Flutter SDK flutter官网下载:https://flutter.io/sdk-arc ...
- Python 哈希表的实现——字典
哈喽大家好,我是咸鱼 接触过 Python 的小伙伴应该对[字典]这一数据类型都了解吧 虽然 Python 没有显式名称为"哈希表"的内置数据结构,但是字典是哈希表实现的数据结构 ...
- springBoot + 工厂模式 实现 快递鸟、顺丰和快递100的物流查询
前言: 在Spring Boot中实现快递鸟.顺丰和快递100的物流查询功能通常需要与它们提供的API进行交互.当然使用他们的API 我们是需要申请和注册,从而去拿到 key 来进行调用.所以为注册的 ...
- 华为ar502H物联网边缘计算网关,在容器内控制/dev/do0开关命令
执行以下命令进行开关do继电开关,可以听见电位器声音. echo -en "\x01" > /dev/do0 echo -en "\x00" > ...
- 用元编程来判断STL类型
在此之前,先来回顾元编程当中的一个重要概念. template<typename _Tp, _Tp __v> struct integral_constant { static con ...
- 解决OpenCV3+VS2015(VS2017)运行时出现debug error abort()has been called的问题
问题描述: 在windows平台上安装opencv后,测试一张图片时,出现了debug error abort()has been called的问题 环境: vs2015 windows 10 op ...
- LIS(比动态规划更快的解法N*logN)
以[1,3,8,17,5,14,10]为例,首先我们需要开设一个栈S保存,栈中的元素S[i]代表了以S[i]结尾的长度为i+1的最长上升子序列的最小取值(0<=i). 然后执行下列算法步骤: ( ...
- 3D网站LOGO动画
相关技术和实现分析 3D模型 帧动画 threejs 推荐用blender创建3d模型,k帧实现从上到下翻转的帧动画 threejs 中执行帧动画,并关联滚动条 threejs 模型材质 Blende ...
- 在k8s中快速搭建基于Prometheus监控系统
公众号「架构成长指南」,专注于生产实践.云原生.分布式系统.大数据技术分享 前言 K8s本身不包含内置的监控工具,所以市场上有不少这样监控工具来填补这一空白,但是没有一个监控工具有prometheus ...
- 解决C#连接MySQL数据库报错 MySqlConnector
如果主机不支持 SSL 连接,则不会使用 SSL 连接. 连接不上. 解决方案:在连接字符串后添加 sslmode = none. <add key="connstring" ...