Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- class FiveSpecialLetters
- {
- static int min, max;
- static List<int> usedNumbers = new List<int>();
- static bool isAnyFound = false;
- static void Main()
- {
- min = int.Parse(Console.ReadLine());
- max = int.Parse(Console.ReadLine());
- char[] vector = new char[5];
- Recursion(vector, 0);
- if(!isAnyFound)
- {
- Console.WriteLine("No");
- }
- Console.WriteLine();
- }
- static void Recursion(char[] vector, int index)
- {
- if(index == vector.Length)
- {
- int weight = 0, j = 1;
- for (int i = 0; i < 5; i++)
- {
- if(usedNumbers.Contains(vector[i]))//ако я има продължава за да не я прибавям към сумата
- {
- continue;
- }
- usedNumbers.Add(vector[i]);
- if (vector[i] == 'a')
- {
- weight += j * 5;
- }
- if (vector[i] == 'b')
- {
- weight += j * -12;
- }
- if (vector[i] == 'c')
- {
- weight += j * 47;
- }
- if (vector[i] == 'd')
- {
- weight += j * 7;
- }
- if (vector[i] == 'e')
- {
- weight += j * -32;
- }
- j++;
- }
- if(weight >= min && weight <= max)
- {
- foreach (var item in vector)
- {
- Console.Write(item);
- }
- Console.Write(" ");
- isAnyFound = true;
- }
- usedNumbers = new List<int>();//по този начин трия всичко
- }
- else
- {
- for (char i = 'a'; i <= 'e'; i++)
- {
- vector[index] = i;
- Recursion(vector, index + 1);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment