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. [bzoj1635]最高的牛

    初始如果没有限制,很显然每一头牛高度都是h当只有一个限制,让h[a]到h[b]的高度都减1即可容易发现两个限制不会相交(否则必然矛盾),只会包含或相离,因此没有影响,直接差分/线段树即可(注意:1.不 ...

  2. 谱文混排之lilypond-book

    Lilypond有自带的谱文混排的工具lilypond-book,但是作为外行,一直很难搞清楚这个操作是怎样做的.很久之前请教过别人,但介于我的个人能力,只有粗浅理解,操作不得要领.在许多信息的拼凑之 ...

  3. tomcat去除项目访问路径限制

    首先打开tomcat的\apache-tomcat-7.0.73\confserver.xml文件 在 </ <Host name="localhost" appBas ...

  4. Trie树(字典树,单词查找树)详解+题目

    什么是字典树? 叫前缀树更容易理解 字典树的样子 Trie又被称为前缀树.字典树,所以当然是一棵树.上面这棵Trie树包含的字符串集合是{in, inn, int, tea, ten, to}.每个节 ...

  5. 『学了就忘』Linux权限管理 — 53、ACL权限详解

    目录 1.什么是ACL权限 2.开启ACL 3.ACL权限的相关命令 (1)设定ACL权限 (2)查询文件的ACL权限 (3)设置文件ACL权限给用户组 (4)给文件夹和里边的文件同时赋予ACL权限 ...

  6. Topcoder 10748 - StringDecryption(dp)

    题面传送门 神仙题. 首先这个两次加密略微有点棘手,咱们不妨先从一次加密的情况入手考虑这个问题.显然,一次加密等价于将加密过的序列划分成若干段,每一段都是 \(xd\) 的形式表示这一段中有 \(x\ ...

  7. 数据仓库和数据集市:ODS、DW、DWD、DWM、DWS、ADS

    @ 目录 数据流向 何为数仓DW 主要特点 与数据库的对比 为何要分层 数据分层 数据运营层ODS 数据仓库层 数据细节层DWD 数据中间层DWM 数据服务层DWS(DWT) 数据应用层ADS 事实表 ...

  8. Linux升级命令yum upgrade和yum update的区别

    Linux升级命令有两个分别是yum upgrade和yum update, 这个两个命令是有区别的: yum -y update 升级所有包同时也升级软件和系统内核 yum -y upgrade 只 ...

  9. linux下vi与vim区别以及vim的使用-------vim编辑时脚本高光显示语法

    vi与vimvi编辑器是所有Unix及Linux系统下标准的编辑器,他就相当于windows系统中的记事本一样,它的强大不逊色于任何最新的文本编辑器.他是我们使用Linux系统不能缺少的工具.由于对U ...

  10. C#集合Dictionary中按值的排序

    C#集合Dictionary中按值的降序排列 static void Main(string[] args) {             Dictionary<string, int> d ...