[CF1303A] Erasing Zeroes

Solution
找到边界然后循环扫一遍数个数即可
#include <bits/stdc++.h>
using namespace std;
int n;
const int N = 1005;
char s[N];
signed main() {
int t;
cin>>t;
while(t--) {
cin>>s+1;
n=strlen(s+1);
int p=1,q=n;
while(s[p]=='0' && p<=n) ++p;
while(s[q]=='0' && q) --q;
int cnt=0;
for(int i=p;i<=q;i++) if(s[i]=='0') ++cnt;
cout<<cnt<<endl;
}
}
[CF1303A] Erasing Zeroes的更多相关文章
- Educational Codeforces Round 82 A. Erasing Zeroes
You are given a string ss. Each character is either 0 or 1. You want all 1's in the string to form a ...
- 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 ...
- [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 82
比较菜只有 A ~ E A.Erasing Zeroes 题目描述: 原题面 题目分析: 使得所有的 \(1\) 连续也就是所有的 \(1\) 中间的 \(0\) 全部去掉,也就是可以理解为第一个 \ ...
- Java 计算N阶乘末尾0的个数-LeetCode 172 Factorial Trailing Zeroes
题目 Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in ...
- [LeetCode] Factorial Trailing Zeroes 求阶乘末尾零的个数
Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in log ...
- [LintCode] Trailing Zeroes 末尾零的个数
Write an algorithm which computes the number of trailing zeros in n factorial. Have you met this que ...
- 【leetcode】Factorial Trailing Zeroes
题目描述: Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be ...
- ✡ leetcode 172. Factorial Trailing Zeroes 阶乘中的结尾0个数--------- java
Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in log ...
随机推荐
- 【WPF学习】第四十六章 效果
WPF提供了可应用于任何元素的可视化效果.效果的目标是提供一种简单的声明式方法,从而改进文本.图像.按钮以及其他控件的外观.不是编写自己的绘图代码,而是使用某个继承自Effect的类(位于System ...
- [redis读书笔记] 第二部分 集群
1. 一个集群会包含多个节点(一个节点就是一个reid是服务器),CLUST MEET <ip><port>可以添加一个node到集群,命令执行后,两个node之间就会进行握手 ...
- 《自拍教程5》Python自动化测试学习思路
前提:熟悉测试业务及流程 任何Python自动化测试的前提,都是必须先熟悉实际测试业务. 任何脱离实际测试业务的自动化都是噱头且无实际意义! 测试的基本流程基本是: 测试需求分析,测试用例设计与评审, ...
- 使用DIV实现页面的遮罩效果
Div实现页面的遮罩 之前没动手搞过,项目有个需求刚好可以用到,就想着去试下,结果发现自己都理解的有问题了. 遮罩的实现是使用opacity或者IE下的filter滤镜来设置透明度的,而且一个div必 ...
- docker device or resource busy
docker-compose -f docker-compose.yml up -d 时候报错 device or resource busy 使用 docker-compose down 会导致一 ...
- SSM/SSH框架的MySQL 读写分离实现的一种简单方法
简介 MySQL已经是使用最为广泛的一种数据库,往往实际使用过程中,为实现高可用及高性能,项目会采用主丛复制的方式实现读写分离.MySQL本身支持复制,通过简单的配置即可实现一主多从的配置,具体实现可 ...
- 【全集】IDEA入门到实战
课程介绍 IDEA是一款功能强悍.非常好用的Java开发工具,近几年编程开发人员对IDEA情有独钟.虽然IDEA功能很强大,但目前市面讲解的不细致.不系统,导致很多IDEA初学者要么无从下手,要么 ...
- emmet笔记
1.div.div${div$}*6 生成 <div class="div1">div1</div> <div class="div2&qu ...
- django 中 cookie与session 相关的知识
cookie :它是一个字典
- Python+PyQT5的子线程更新UI界面的实例《新手必学》
今天小编就为大家分享一篇Python+PyQT5的子线程更新UI界面的实例,具有很好的参考价值,希望对大家有所帮助.一起跟随小编过来看看吧子线程里是不能更新UI界面的,在移动端方面.Android的U ...