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的更多相关文章

  1. 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 ...

  2. 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 ...

  3. [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 ...

  4. 【题解】Educational Codeforces Round 82

    比较菜只有 A ~ E A.Erasing Zeroes 题目描述: 原题面 题目分析: 使得所有的 \(1\) 连续也就是所有的 \(1\) 中间的 \(0\) 全部去掉,也就是可以理解为第一个 \ ...

  5. 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 ...

  6. [LeetCode] Factorial Trailing Zeroes 求阶乘末尾零的个数

    Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be in log ...

  7. [LintCode] Trailing Zeroes 末尾零的个数

    Write an algorithm which computes the number of trailing zeros in n factorial. Have you met this que ...

  8. 【leetcode】Factorial Trailing Zeroes

    题目描述: Given an integer n, return the number of trailing zeroes in n!. Note: Your solution should be ...

  9. ✡ 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 ...

随机推荐

  1. 并发编程之Master-Worker模式

    我们知道,单个线程计算是串行的,只有等上一个任务结束之后,才能执行下一个任务,所以执行效率是比较低的. 那么,如果用多线程执行任务,就可以在单位时间内执行更多的任务,而Master-Worker就是多 ...

  2. java虚拟机jvm启动后java代码层面发生了什么?

    java虚拟机jvm启动后java代码层面发生了什么? 0000 我想验证的事情 java代码在被编译后可以被jdk提供的java命令进行加载和运行, 在我们的程序被运行起来的时候,都发生了什么事情, ...

  3. Windows下无法颜色转义

    只需在最前面添加 import os os.system("") 参考文献:https://blog.csdn.net/ytzlln/article/details/8194524 ...

  4. docker:搭建ELK 开源日志分析系统

    ELK 是由三部分组成的一套日志分析系统, Elasticsearch: 基于json分析搜索引擎,Elasticsearch是个开源分布式搜索引擎,它的特点有:分布式,零配置,自动发现,索引自动分片 ...

  5. docker实战部署Javaweb项目

    一.部署环境说明 docker服务版本:version 18.09.0nginx服务版本:version: nginx/1.15.10redis服务版本:version: redis/5.0.3tom ...

  6. Oracle查询如何才能行转列?-sunziren

    原创文章,转载务必注明出处. 今天工作的时候,碰到一个问题,涉及oracle行转列,用了半小时解决,因此在这里写个博客记录一下解决办法. 原数据库表的数据是: 想要达到的效果是: 经过思考,这是一个o ...

  7. 重启防火墙(iptables)命令#service iptable restart失效

    Redirecting to /bin/systemctl restart iptables.ser linux下执行防火墙相关指令报错: Redirecting to /bin/systemctl ...

  8. 软考复习之UML设计篇

    UML统一建模语言 构件图:描述系统的物理结构,它可以用来显示程序代码如何分解成模块 部署图:描述系统中硬件和软件的物理结构,它描述构成系统架构的软件构件,处理器和设备 用例图:描述系统与外部系统及用 ...

  9. MacBook Pro安装VMware Fusion 11

    下载地址 https://www.vmware.com/cn/products/fusion/fusion-evaluation.html 序列号 TX1NF-PPVRW-A1XAX-X5PVZ-Q7 ...

  10. axios上传图片遇见问题

    博客后台,vue-quill-editor 编辑器,上传图片,使用sm.ms图床,上传逻辑需要自定义,element-ui,el-upload,自定义http-request上传图片, 'conten ...