Content

给出一个长度为 \(n\) 字符串 \(s\),请将开头为 \(\texttt{ogo}\),后面带若干个 \(\texttt{go}\) 的子串替换成 \(\texttt{***}\),然后输出。

数据范围:\(1\leqslant n\leqslant 100\)。

Solution

我们考虑遍历每个字符,如果这个字符是 \(\texttt{o}\),并且后面两个字符是 \(\texttt{go}\),那么直接替换成 \(\texttt{***}\),并且往后搜有没有 \(\texttt{go}\),直到没有为止。

Code

#include <cstdio>
#include <cstring>
using namespace std; int n;
char a[107]; int main() {
scanf("%d%s", &n, a);
int cur = 0;
while(cur < n) {
if(a[cur] == 'o' && a[cur + 1] == 'g' && a[cur + 2] == 'o') {
printf("***");
cur += 3;
while(a[cur] == 'g' && a[cur + 1] == 'o')
cur += 2;
} else {
printf("%c", a[cur]);
cur++;
}
}
return 0;
}

CF729A Interview with Oleg 题解的更多相关文章

  1. Interview with Oleg

    Interview with Oleg time limit per test 1 second memory limit per test 256 megabytes input standard ...

  2. 【57.97%】【codeforces Round #380A】Interview with Oleg

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  3. 【Codeforces 738A】Interview with Oleg

    http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...

  4. [CF738A]Interview with Oleg(模拟)

    题目链接:http://codeforces.com/contest/738/problem/A 题意:把ogo..ogo替换成***. 写的有点飘,还怕FST.不过还好 #include <b ...

  5. CodeForces 738A Interview with Oleg

    模拟. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #includ ...

  6. CF793A Oleg and shares 题解

    Content 有 \(n\) 支股票,第 \(i\) 支股票原价为 \(a_i\) 卢布.每秒钟可能会有任意一支股票的价格下降 \(k\) 卢布,以至于降到负数.求所有股票的价格均变得相同所要经过的 ...

  7. codeforces 631A Interview

    A. Interview time limit per test 1 second memory limit per test 256 megabytes input standard input o ...

  8. leetcode & lintcode 题解

    刷题备忘录,for bug-free 招行面试题--求无序数组最长连续序列的长度,这里连续指的是值连续--间隔为1,并不是数值的位置连续 问题: 给出一个未排序的整数数组,找出最长的连续元素序列的长度 ...

  9. Codeforces Round #344 (Div. 2) A. Interview 水题

    A. Interview 题目连接: http://www.codeforces.com/contest/631/problem/A Description Blake is a CEO of a l ...

随机推荐

  1. spring boot(三)整合 redis

    Spring boot 集成redis 为什么要用redis,它解决了什么问题? Redis 是一个高性能的key-value内存数据库.它支持常用的5种数据结构:String字符串.Hash哈希表. ...

  2. 打开order by的大门,一探究竟《死磕MySQL系列 十二》

    在日常开发工作中,你一定会经常遇到要根据指定字段进行排序的需求. 这时,你的SQL语句类似这样. select id,phone,code from evt_sms where phone like  ...

  3. Codeforces 571E - Geometric Progressions(数论+阿巴细节题)

    Codeforces 题目传送门 & 洛谷题目传送门 u1s1 感觉此题思维难度不太大,不过大概是细节多得到了精神污染的地步所以才放到 D1E 的罢((( 首先我们对所有 \(a_i,b_i\ ...

  4. Jumpserver堡垒机容器化部署

    JumpServer 是符合 4A 的专业运维安全审计系统. 前提条件 已部署docker Jumpserver 对外需要开放 80 443 和 2222 端口 服务器.数据库.redis 等依赖组件 ...

  5. a这个词根

    a是个词根,有三种意思:1. 以某种状态或方式,如: ablaze, afire, aflame, alight, aloud, alive, afloat等2. at, in, on, to sth ...

  6. acute

    In Euclidean geometry, an angle is the figure formed by two rays, called the sides of the angle, sha ...

  7. mongDB进阶

    Mongo进阶 聚合 聚合操作将来自多个文档的值组合在一起,并且可以对分组数据执行各种操作以返回单个结果. 文档进入多阶段管道,将文档转换为聚合结果 聚合管道 例子: 第一阶段:过滤,$match 第 ...

  8. 使用Mock测试

    一.前言 在前面的章节我们介绍过 Junit 的使用,也了解过 spring-test,今天我们来了解一个新玩意 -- mock 测试.这里仅仅做一个入门,对返回视图和返回 Json 数据的方法进行测 ...

  9. ComponentScan注解的使用

    在项目初始化时,会将加@component,@service...相关注解的类添加到spring容器中. 但是项目需要,项目初始化时自动过滤某包下面的类,不将其添加到容器中. 有两种实现方案, 1.如 ...

  10. keepalived 高可用lvs的dr模型(vip与dip不在同一网段)

    现在rs1和rs2上面安装httpd并准备测试页 [root@rs1 ~]# yum install httpd -y [root@rs1 ~]# echo "this is r1" ...