农夫约翰把杂志上所有的文章摘抄了下来并把它变成了一个长度不超过 删减(春季每日一题 27)_思维 的字符串 删减(春季每日一题 27)_字符串_02

他希望从 删减(春季每日一题 27)_字符串_02 中删除子串 删减(春季每日一题 27)_枚举_04

农夫约翰在 删减(春季每日一题 27)_字符串_02 中从头开始寻找子串 删减(春季每日一题 27)_枚举_04,一旦找到,就将它从 删减(春季每日一题 27)_字符串_02 中删除,然后再次从头开始寻找(而不是接着往下找)。

他重复这个操作直到 删减(春季每日一题 27)_字符串_02 中没有子串 删减(春季每日一题 27)_枚举_04 为止。

注意,删除一个子串 删减(春季每日一题 27)_枚举_04 可能会导致一个新的子串 删减(春季每日一题 27)_枚举_04 的出现。

请帮助约翰完成这些操作并输出最后的 删减(春季每日一题 27)_字符串_02

输入格式
第一行包含字符串 删减(春季每日一题 27)_字符串_02

第二行包含字符串 删减(春季每日一题 27)_枚举_04

输出格式
输出操作完成后的 删减(春季每日一题 27)_字符串_02

保证最终字符串 删减(春季每日一题 27)_字符串_02 不为空。

数据范围
删减(春季每日一题 27)_字符串_02 的长度不超过 删减(春季每日一题 27)_思维删减(春季每日一题 27)_枚举_04 的长度不超过 删减(春季每日一题 27)_字符串_20 且不超过 删减(春季每日一题 27)_字符串_02 的长度,字符串中只出现小写字母。

输入样例:

whatthemomooofun
moo

输出样例:

whatthefun

#include<iostream>

using namespace std;

int main(){

string s, t;

cin >> s >> t;
int tlen = t.size();
string res = "";
for(int i = 0; i < s.size(); i++){

res += s[i];
if(res.size() >= tlen && res.substr(res.size() - tlen) == t){
res.erase(res.end() - tlen, res.end());
}
}

cout << res << endl;

return 0;
}