农夫约翰把杂志上所有的文章摘抄了下来并把它变成了一个长度不超过 的字符串 。
他希望从 中删除子串 。
农夫约翰在 中从头开始寻找子串 ,一旦找到,就将它从 中删除,然后再次从头开始寻找(而不是接着往下找)。
他重复这个操作直到 中没有子串 为止。
注意,删除一个子串 可能会导致一个新的子串 的出现。
请帮助约翰完成这些操作并输出最后的 。
输入格式
第一行包含字符串 。
第二行包含字符串 。
输出格式
输出操作完成后的 。
保证最终字符串 不为空。
数据范围
的长度不超过 , 的长度不超过 且不超过 的长度,字符串中只出现小写字母。
输入样例:
whatthemomooofun
moo
输出样例:
whatthefun
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;
}