using System; using System.Text; namespace Csharp { class Program { static string Word, Bomb; static void Main(string[] args) { Word = Console.ReadLine(); Bomb = Console.ReadLine(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < Word.Length; ++i) { sb.Append(Word[i]); if (CanExplode(sb)) sb.Remove(sb.Length - Bomb.Length, Bomb.Length); } if (sb.Length == 0) Console.WriteLine("FRULA"); else Console.WriteLine(sb.ToString()); } static bool CanExplode(StringBuilder sb) { if (sb.Length < Bomb.Length) return false; if (sb[sb.Length - 1] != Bomb[Bomb.Length - 1]) return false; for (int i = 0; i < Bomb.Length; ++i) { if (sb[sb.Length - 1 - i] != Bomb[Bomb.Length - 1 - i]) return false; } return true; } } } |