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 ...
随机推荐
- C#使用SqlSugar操作MySQL数据库实现简单的增删改查
公众号「DotNet学习交流」,分享学习DotNet的点滴. SqlSugar简介 SqlSugar 是一款 老牌 .NET 开源多库架构ORM框架(EF Core单库架构),由果糖大数据科技团队 维 ...
- top命令和ps命令
top 命令和 ps 命令 ps 命令 ps 命令查看系统的瞬时信息.通常使用ps -ef | grep 进程名, -e 代表显示所有进程,-f 表示做一个更为完整的输出.经常使用这个命令获得进程的 ...
- JVM整理笔记
1.JVM位置 JVM是作用在操作系统之上的,它与硬件没有直接的交互 2.JVM体系结构 3.类装载器ClassLoader 类装载器:负责加载class文件,class文件在文件开头有特定的文件标示 ...
- Bugku CTF web题
web2 查看网页源码,发现flag
- postman——预处理和断言
一.预处理 Pre-request Scrip 1.Pre-request Script是集合中请求发送之前需要执行的代码片段 2.请求参数中包含一个随机数或者请求header中包括一个时间戳,或者你 ...
- Windows Server 2008 R2 & Windows Server 2012 R2 无法通过update更新的解决方法
windows Server 2008 r2 无法通过update更新的解决方法 注意:目前windows Server系列操作系统已经完全停止支持. 1.安装 SP1补丁 KB976932 点击:微 ...
- freemarker实现自定义标签
freemarker实现自定义标签 freemarker实现自定义标签其实并没有什么难度,这个功能我们叫自定义标签,在官网中称为指令,也并不是什么高级技术,只是大家没发现而已,参考下官网文档就能实现: ...
- Kafka 的基本使用
Kafka 是一款分布式消息发布和订阅系统,最初的目的是作为一个日志提交系统来使用.现在,也可以作为一般的消息中间件来使用. 组件介绍 相关的组件介绍如下表所示: 组件 解释 Broker 实际 Ka ...
- Spring Batch 的基本使用
简介 A lightweight, comprehensive batch framework designed to enable the development of robust batch a ...
- react+echarts出现“There is a chart instance already initialized on the dom.”
写了一个关于echatrs组件,报错dom重复 配置信息从props拿 let chart; useEffect(() => { if (chart) { updateChartView(); ...