A - Dubstep
Problem 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.
Examples
Input
WUBWUBABCWUB
Output
ABC
Input
WUBWEWUBAREWUBWUBTHEWUBCHAMPIONSWUBMYWUBFRIENDWUB
Output
WE ARE THE CHAMPIONS MY FRIEND
Note
In the first sample: "WUBWUBABCWUB" = "WUB" + "WUB" + "ABC" + "WUB". That means that the song originally consisted of a single word "ABC", and all words "WUB" were added by Vasya.
In the second sample Vasya added a single word "WUB" between all neighbouring words, in the beginning and in the end, except for words "ARE" and "THE" — between them Vasya added two "WUB".
解题思路:题目的意思就是一个英文句子(没有标点符号)中每个空格处至少都会插入一个字符串"WUB",要求输出正常(单词之间是一个空格,并且开头前和结尾后没有空格)的英语句子(删掉所有的子串"WUB"),java简单水过。
AC代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
String obj = scan.nextLine().replaceAll("WUB"," ");
Scanner in = new Scanner(obj);
String[] str = new String[105];int k=0;
while(in.hasNext()){str[k++]=in.next();}
for(int i=0;i<k;++i)
System.out.print(str[i]+(i==k-1?"\n":" "));
}
}
A - Dubstep的更多相关文章
- CF 208A Dubstep(简单字符串处理)
题目链接: 传送门 Dubstep Time Limit: 1000MS Memory Limit: 32768 KB Description Vasya works as a DJ in t ...
- Codeforces Round #130 (Div. 2) A. Dubstep
题目链接: http://codeforces.com/problemset/problem/208/A A. Dubstep time limit per test:2 secondsmemory ...
- Codeforces 208A:Dubstep(字符串)
题目链接:http://codeforces.com/problemset/problem/208/A 题意 给出一个字符串,将字符串中的WUB给删去,如果两个字母间有WUB,则这两个字母用空格隔开 ...
- CF208A Dubstep 题解
Content 有一个字符串被变换了.其中在这个字符串的前面加了 \(\geqslant 0\) 个 WUB,每个单词(由空格间隔)之间加了 \(\geqslant 1\) 个 WUB,在这个字符串的 ...
- 基于ionic+cordova+angularJs从零开始搭建自己的移动端H5 APP
这里详细介绍下如何用ionic+cordova+angularjs搭建自己的移动端app,包括环境搭建,框架使用等,具体项目已放置在github上,可下载下来自行启动. 下载地址:https://gi ...
- Codeforces Round #130 (Div. 2)
A. Dubstep 字符串模拟. string.find()用法 string str; size_t pos = str.find("WUB"); // 返回匹配的第一个位置 ...
- ionic+cordova+angularJs
ionic+cordova+angularJs 这里详细介绍下如何用ionic+cordova+angularjs搭建自己的移动端app,包括环境搭建,框架使用等,具体项目已放置在github上,可下 ...
- Codeforces 208A-Dubstep(字符串)
Vasya works as a DJ in the best Berland nightclub, and he often uses dubstep music in his performanc ...
- AngularJS基础02 神奇的数据绑定(Binding)
作者:arccosxy 转载请注明出处:http://www.cnblogs.com/arccosxy/ 上一节,我们在JS中声明一个scope变量然后在HTML直接访问它,这非常的酷.但是Angu ...
随机推荐
- 【sqli-labs】 less25 GET- Error based -All you OR&AND belong to us -string single quote(GET型基于错误的去除了or和and的单引号注入)
加单引号 order by一下 http://localhost/sqli-labs-master/Less-25/?id=1' order by 1%23 order by 变成了der by 下面 ...
- 10.3 .NET 3.5 中的扩展方法
10.3.4 用 Select 方法和匿名类型进行投影 class Program { static void Main(string[] args) { , ).Where(x => x % ...
- 软件工程1916|W(福州大学)_助教博客】团队Beta冲刺作业(第9次)成绩公示
1. 作业链接: 项目Beta冲刺(团队) 2. 评分准则: 本次作业包括现场Beta答辩评分(映射总分为100分)+团队互评分数(总分40分)+博客分(总分130分)+贡献度得分,其中博客分由以下部 ...
- 值得收藏--GitHub Top 20 开源项目
参考链接:https://github.com/Aufree/trip-to-iOS/blob/master/Top-100.md 项目名称 项目 ...
- uwsgi部署django,里的request调用的接口响应慢解决方法
解决方法,增加2个线程 uwsgi.ini 配置如下 chdir=/var/www/Ultramanpidfile=/tmp/uwsgi.pidmodule=Ultraman.wsgimaster=t ...
- [tyvj1935 Poetize3]导弹防御塔 (二分图多重匹配)
传送门 Description Freda控制着N座可以发射导弹的防御塔.每座塔都有足够数量的导弹,但是每座塔每次只能发射一枚.在发射导弹时,导弹需要T1秒才能从防御塔中射出,而在发射导弹后,发射这枚 ...
- Linux下进程与线程的区别
https://www.cnblogs.com/fah936861121/articles/8043187.html https://my.oschina.net/cnyinlinux/blog/36 ...
- 爬虫系列(二) Chrome抓包分析
在这篇文章中,我们将尝试使用直观的网页分析工具(Chrome 开发者工具)对网页进行抓包分析,更加深入的了解网络爬虫的本质与内涵 1.测试环境 浏览器:Chrome 浏览器 浏览器版本:67.0.33 ...
- 10.IDEAD 的xml中配置DTD
此时发现最后一行已经变成绿色就说明可以了,有提示了
- (转载)关于初学者上传文件到github的方法
说来也惭愧,我是最近开始用github,小白一个,昨天研究了一个下午.终于可以上传了,所以今天写点,一来分享是自己的一些经验,二来也是做个记录,万一哪天又不记得了:) 废话不多说,直接来,这次主要介绍 ...