题目链接: 传送门

Dubstep

Time Limit: 1000MS     Memory Limit: 32768 KB

Description

Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performance. Recently, he has decided to take a couple of old songs and make dubstep remixes from them.
Let's assume that a song consists of some number of words. To make the dubstep remix of this song, Vasya inserts a certain number of words "WUB" before the first word of the song (the number may be zero), after the last word (the number may be zero), and between words (at least one between any pair of neighbouring words), and then the boy glues together all the words, including "WUB", in one string and plays the song at the club.
For example, a song with words "I AM X" can transform into a dubstep remix as "WUBWUBIWUBAMWUBWUBX" and cannot transform into "WUBWUBIAMWUBX".
Recently, Petya has heard Vasya's new dubstep track, but since he isn't into modern music, he decided to find out what was the initial song that Vasya remixed. Help Petya restore the original song.

Input

The input consists of a single non-empty string, consisting only of uppercase English letters, the string's length doesn't exceed 200 characters. It is guaranteed that before Vasya remixed the song, no word contained substring "WUB" in it; Vasya didn't change the word order. It is also guaranteed that initially the song had at least one word.

Output

Print the words of the initial song that Vasya used to make a dubsteb remix. Separate the words with a space.

Sample Input

WUBWUBABCWUB
WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB

Sample Output

ABC
WE ARE THE CHAMPIONS MY FRIEND 

思路:

简单字符串处理,删除"WUB"输出剩下的字符。

#include<iostream>
#include<cstdio>
#include<string>
using namespace std;

int main()
{
    string str,tmp;
    cin >> str;
    int len = str.size();
    for (int i = 0;i < len;)
    {
        string s = str.substr(i,3);
        if (s == "WUB")
        {
            i += 3;
        }
        else
        {
            tmp += str[i];
            i++;
            string s = str.substr(i,3);
            if (s == "WUB")
            {
                tmp += ' ';
            }
        }
    }
    if (tmp != "")
        cout << tmp << endl;
    return 0;
} 

CF 208A Dubstep(简单字符串处理)的更多相关文章

  1. 第一部分之简单字符串SDS(第二章)

    一,什么是SDS? 1.引出SDSC字符串:c语言中,用空字符结尾的字符数组表示字符串简单动态字符串(SDS):Redis中,用SDS来表示字符串.在Redis中,包含字符串值的键值对在底层都是由SD ...

  2. hdu 5059 简单字符串处理

    http://acm.hdu.edu.cn/showproblem.php?pid=5059 确定输入的数是否在(a,b)内 简单字符串处理 #include <cstdio> #incl ...

  3. C 封装一个通用链表 和 一个简单字符串开发库

    引言 这里需要分享的是一个 简单字符串库和 链表的基库,代码也许用到特定技巧.有时候回想一下, 如果我读书的时候有人告诉我这些关于C开发的积淀, 那么会走的多直啊.刚参加工作的时候做桌面开发, 服务是 ...

  4. 1442: Neo 的简单字符串(字符串)

    1442: Neo 的简单字符串 时间限制: 10 Sec 内存限制: 128 MB 提交: 9 解决: 3 统计 题目描述 Neo 给你一系列字符串,请你输出字符串中的不同单词个数以及总单词个数. ...

  5. Codeforces 208A:Dubstep(字符串)

    题目链接:http://codeforces.com/problemset/problem/208/A 题意 给出一个字符串,将字符串中的WUB给删去,如果两个字母间有WUB,则这两个字母用空格隔开 ...

  6. Java实验--关于简单字符串回文的递归判断实验

    首先题目要求写的是递归的实验,一开始没注意要求,写了非递归的方法.浪费了一些时间,所谓吃一堑长一智.我学习到了以后看实验的时候要认真看实验中的要求,防止再看错. 以下是对此次的实验进行的分析: 1)递 ...

  7. python 简单字符串字典加密

    1 def crypt(source,key): from itertools import cycle result='' temp=cycle(key) for ch in source: res ...

  8. 洛谷 简单字符串 'P1055ISBN号码' 问题

    题目描述如下: 知识点①:char数组与int型数字进行运算时,需要将 char[i]-'0' .比如 char c[5]; int i; for(i=0;i<5;i++) scanf(&quo ...

  9. c# 进程间的通信实现之一简单字符串收发

       使用Windows API实现两个进程间(含窗体)的通信在Windows下的两个进程之间通信通常有多种实现方式,在.NET中,有如命名管道.消息队列.共享内存等实现方式,这篇文章要讲的是使用Wi ...

随机推荐

  1. css3实践之摩天轮式图片轮播+3D正方体+3D标签云(perspective、transform-style、perspective-origin)

    本文主要通过摩天轮式图片轮播的例子来讲解与css3 3D有关的一些属性. demo预览: 摩天轮式图片轮播(貌似没兼容360 最好用chrome) 3D正方体(chrome only) 3D标签云(c ...

  2. <实训|第十一天>学习一下linux中的进程,文件查找,文件压缩与IO重定向

    [root@localhost~]#序言 在今后的工作中,运维工程师每天的例行事务就是使用free -m,top,uptime,df -h...每天都要检查一下服务器,看看是否出现异常.那么今天我们就 ...

  3. 年中review

    1. 做好已知的各种项目,争取能成立固定团队 (项目一期争取能在本月上线)2. 横向扩展技术学习,了解各种技术,加强技术素养(从Server到前端,现在要关注的知识点越来越多,fighting...) ...

  4. wap端开发必须基础

    1. nitial-scale=1.0 确保网页加载时,以 1:1 的比例呈现,不会有任何的缩放. 在移动设备浏览器上,通过为 viewport meta 标签添加 user-scalable=no  ...

  5. SDRAM和dcfifo的联合

    SDRAM和dcfifo的联合 设计原理 在"SDRAM突发读写页"实验中,留下了一个问题,就是从SDRAM读取数据的速度要与SDRAM的驱动时钟同步,这就造成了读出的数据的速率过 ...

  6. 前端程序员应该知道的15个 jQuery 小技巧

    下面这些简单的小技巧能够帮助你玩转jQuery. 返回顶部按钮 预加载图像 检查图像是否加载 自动修复破坏的图像 悬停切换类 禁用输入字段 停止加载链接 切换淡入/幻灯片 简单的手风琴 让两个div高 ...

  7. Social Emotional Computing

    from:数理情感学 http://choudh.blogchina.com/2556171.html 第五节  情感的三要素 人对于某一事物的情感,不仅取决于该事物的品质特性(如物理特性.化学特性. ...

  8. Android之Activity启动模式

    正常模式 每个应用都有一个任务栈,任务栈中保存着已创建的Activity,先创建的Activity先入栈,栈顶是当前正在显示的activity(running),这是正常模式下的Activity的管理 ...

  9. 认真地搭建python开发环境

    面对不同python不同的版本以及各种各样的三方库,为了以后有必要学习一下怎样更好地搭建开发环境. python 2.7 作为控制台脚本 pycharm下: python 3.4 python 2.7 ...

  10. Webpack配置示例和详细说明

    /* * 请使用最新版本nodejs * 默认配置,是按生产环境的要求设置,也就是使用 webpack -p 命令就可以生成正式上线版本. * 也可以使用 webpack -d -w 命令,生成用于开 ...