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 ...
随机推荐
- 2023-11-25:用go语言,给定一个数组arr,长度为n,表示n个格子的分数,并且这些格子首尾相连, 孩子不能选相邻的格子,不能回头选,不能选超过一圈, 但是孩子可以决定从任何位置开始选,也可以
2023-11-25:用go语言,给定一个数组arr,长度为n,表示n个格子的分数,并且这些格子首尾相连, 孩子不能选相邻的格子,不能回头选,不能选超过一圈, 但是孩子可以决定从任何位置开始选,也可以 ...
- 关于如何来测一款app的思考
最近工作当中需要整体测一遍app,需要全方面思考并且尽可能覆盖所有待测点,因为整理总结了这篇关于app测试的总体大纲 一.功能测试 1.1界面测试 1.1.1导航测试 ---是否易于导航.导航是否直观 ...
- Django的staticfiles库
staticfiles 库是 Django 提供的一个用于管理静态文件的库,它提供了一些工具和函数来帮助开发者在 Django 应用程序中管理和提供静态文件服务. 在 Django 应用程序中,静态文 ...
- 深入理解HarmonyOS UIAbility:生命周期、WindowStage与启动模式探析
本文分享自华为云社区<深入理解HarmonyOS UIAbility:生命周期.WindowStage与启动模式探析>,作者:柠檬味拥抱. UIAbility组件概述 UIAbility组 ...
- 离散傅里叶变换DFT的应用
目录 一维DFT 1 DFT的相关内容 2 DFT计算结果验证 3 DFT的时频曲线分析 4 DFT的应用 二维DFT 1 DFT在图像处理时的相关内容 2 DFT滤波应用 一维DFT 1 DFT的相 ...
- Aiganize组局小程序开发手册
1. 开发阶段概述: 第一阶段: 针对组局和参局的产品功能落地完善小程序, 修改前端界面,去除冗余, 完善数据库设计 完善组局参局的功能 让每个用户能参与组局大厅的组局 让用户能申请为组局者发起组局, ...
- C++ 共享内存ShellCode跨进程传输
在计算机安全领域,ShellCode是一段用于利用系统漏洞或执行特定任务的机器码.为了增加攻击的难度,研究人员经常探索新的传递ShellCode的方式.本文介绍了一种使用共享内存的方法,通过该方法,两 ...
- Vue2.0 学习 第二组 语法模板
本笔记主要参考菜鸟教程和官方文档编写. 1.文本绑定 一般在dom中用{{}}标时,并且在vue构造体内的data中定义文本内容 <div id="app"> & ...
- SpringBoot测试用例的一些小技巧~
场景一:不想因为测试而对数据库产生脏数据 @Test public void testInsert() { User user = new User(); user.setUsername(" ...
- SpringBoot使用maven打jar包配置
在pom.xml文件中加入依赖 <parent> <groupId>org.springframework.boot</groupId> <artifactI ...