[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 ...
随机推荐
- 博客圆美化主题推荐之Slience
博客圆美化主题推荐之Slience 一.前言 本博客美化主题作者为:Esofar,本文仅在教导如何快速把该美化主题应用到自己的博客中,详细部署内容见Silence - 专注于阅读的博客园主题. 二.博 ...
- 《Head first设计模式》之装饰者模式
装饰者模式动态地将责任附加到对象上.若要扩展功能,装饰者提供了比继承更有弹性的替代方案. 星巴兹是以扩张速度最快而闻名的咖啡连锁店.由于扩张速度太快,他们准备更新订单系统,以合乎他们的饮料供应要求. ...
- k8s系列---StorageClass
介绍这个概念前,需要提前知道存储卷pv/pvc之类的概念. 之前的文章有关于EFK日志系统的介绍,里面的环境是测试环境,完全按照教程一步步的操作,甚至注释掉了持久化存储,当真正线上部署时,又抓虾,打开 ...
- VNC 远程桌面 连接(安装桌面程序)
1.修改linux启动方式 # vi /etc/inittab 将3改为5 id:5:initdefault: 2.关闭防火墙(或者单独打开接口) #s ...
- es5实现一个class
es5实现一个class https://juejin.im/post/5ac1c5bf518825558949f898#heading-9
- weblogic非正常关闭,<BEA-141281>错误
在域下 find -name *.lok , 全删除: 在域下 find -name *.DAT,全删除: 然后就可以正常启动了
- K8S ConfigMap使用
k8s系列文章: 什么是K8S configmap是k8s的一个配置管理组件,可以将配置以key-value的形式传递,通常用来保存不需要加密的配置信息,加密信息则需用到Secret,主要用来应对以下 ...
- git 指令笔记
狂躁,太狂躁!!赶上过年,赶上自己的懒癌,12月底就学完的教程直到今天才整理笔记,中途沉默在游戏中..... 只给出Windows下git指令操作,推荐大家去廖雪峰前辈那里学习(百度搜索:廖雪峰的官方 ...
- 在debian10启动器中添加自定义应用
首先要添加一个desktop类型的文件,搜索一下即可 若将desktop文件放在/usr/share/applicatios/中,需要执行update-desktop-database使新添加的应用生 ...
- XPath简介、功能及使用方法
html = '''<html><head><title>The Dormouse's story</title></head><bo ...