Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace Rage_Quit
- {
- class Program
- {
- static void Main(string[] args)
- {
- string input = Console.ReadLine().ToUpper();
- List<char> result = new List<char>();
- List<char> currResult = new List<char>();
- for (int i = 0; i < input.Length; i++)
- {
- char ch = input[i];
- if (!char.IsNumber(ch))
- {
- currResult.Add(ch);
- }
- if (char.IsNumber(ch))
- {
- int count = 0;
- if (i < input.Length - 1 && char.IsNumber(input[i + 1]))
- {
- string str = input.Substring(i, 2);
- count = int.Parse(str.ToString());
- }
- else
- {
- count = int.Parse(ch.ToString());
- }
- if (count > 0)
- {
- for (int j = 0; j < count; j++)
- {
- result.AddRange(currResult);
- }
- }
- currResult.Clear();
- }
- }
- string res = new string(result.ToArray());
- Console.WriteLine("Unique symbols used: {0}", res.Distinct().Count());
- Console.WriteLine(res);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement