Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _04.FiveSpecialLetters
- {
- class Program
- {
- static void Main(string[] args)
- {
- int start = int.Parse(Console.ReadLine());
- int end = int.Parse(Console.ReadLine());
- char[] chars = { 'a', 'b', 'c', 'd', 'e' };
- bool foundCombination = false;
- List<string> combinations = new List<string>();
- for (int c1 = 0; c1 < chars.Length; c1++)
- {
- for (int c2 = 0; c2 < chars.Length; c2++)
- {
- for (int c3 = 0; c3 < chars.Length; c3++)
- {
- for (int c4 = 0; c4 < chars.Length; c4++)
- {
- for (int c5 = 0; c5 < chars.Length; c5++)
- {
- string combinationWithRepetitions = string.Concat(chars[c1], chars[c2], chars[c3], chars[c4], chars[c5]);
- char[] combination = combinationWithRepetitions.Distinct().ToArray();
- if(Calculate(combination) >= start && Calculate(combination) <= end)
- {
- foundCombination = true;
- combinations.Add(combinationWithRepetitions);
- }
- }
- }
- }
- }
- }
- if (foundCombination)
- {
- combinations.Sort();
- foreach (string currentcombination in combinations)
- {
- Console.Write(currentcombination + " ");
- }
- }
- else
- {
- Console.WriteLine("No");
- foundCombination = true;
- }
- }
- static int Calculate(char[] combination)
- {
- int weight = 0;
- int index = 0;
- for (int i = 1; i <= combination.Length; i++, index++)
- {
- switch(combination[index])
- {
- case 'a':
- weight += i * 5;
- break;
- case 'b':
- weight += i * -12;
- break;
- case 'c':
- weight += i * 47;
- break;
- case 'd':
- weight += i * 7;
- break;
- case 'e':
- weight += i * -32;
- break;
- }
- }
- return weight;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement