[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 ...
随机推荐
- 图像里的"白噪声"——电视机搜不到台时雪花斑点的形成原因
作者:❄️固态二氧化碳❄️ (主页) 链接:图像里的"白噪声"--电视机搜不到台时雪花斑点的形成原因 - 固态二氧化碳的博客 - CSDN博客 来源:CSDN博客 发表时间:201 ...
- php 搭建webSocket
<?php //2.设计一个循环挂起WebSocket通道,进行数据的接收.处理和发送 //对创建的socket循环进行监听,处理数据 function run(){ //死循环,直到socke ...
- AJAX传输图片文件
AJAX传输 例:const xhr = new XMLHttpRequest(); // 此方法因为状态改变被调用多次,实测执行三次(1->2->4) xhr.onreadystatec ...
- 论文翻译:Speech Enhancement Based on the General Transfer Function GSC and Postfiltering
论文地址:基于通用传递函数GSC和后置滤波的语音增强 博客作者:凌逆战 博客地址:https://www.cnblogs.com/LXP-Never/p/12232341.html 摘要 在语音增强应 ...
- Vue之Vuex的使用
重点看懂这张图: 重点记住: 1.Mutation 必须是同步函数,即mutations里只能处理同步操作. 2.如果处理的是同步操作可直接commit提交mutations更改state,如果是异步 ...
- css position absolute相对于父元素的设置方式
手机赚钱怎么赚,给大家推荐一个手机赚钱APP汇总平台:手指乐(http://www.szhile.com/),辛苦搬砖之余用闲余时间动动手指,就可以日赚数百元 大家知道css的position abs ...
- Github搜索技巧
按仓库名称.说明或自述文件内容搜索 通过 in 限定符,您可以将搜索限制为仓库名称.仓库说明.自述文件内容或这些的任意组合. 如果省略此限定符,则只搜索仓库名称和说明. 限定符 示例 in:name ...
- JVM类加载器是否可以加载自定义的String
前言 曾经有一次,面试官问到类加载机制,相信大多数小伙伴都可以答上来双亲委派机制,也都知道JVM出于安全性的考虑,全限定类名相同的String是不能被加载的.但是如果加载了,会出现什么样的结果呢?异常 ...
- phpstrom laravel代码自动提示
1.安装composer包 composer require barryvdh/laravel-ide-helper dev-master 2.目录:\config\app.php 的'provide ...
- [Docker] 使用docker inspect查看宿主机与容器的共享目录
docker inspect 容器名,可以查看到容器的元信息,在返回的j'son信息里面有个Mounts字段可以看到挂载目录 "Mounts": [ { "Type&qu ...