Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace _4.FiveSpecialLetters
- {
- using System;
- public class FiveSpecialLetters
- {
- public static void Main(string[] args)
- {
- checked
- {
- long startNum = long.Parse(Console.ReadLine());
- long endNum = long.Parse(Console.ReadLine());
- bool foundRightSequence = false;
- for (char i = 'a'; i <= 'e'; i++)
- {
- for (char j = 'a'; j <= 'e'; j++)
- {
- for (char k = 'a'; k <= 'e'; k++)
- {
- for (char m = 'a'; m <= 'e'; m++)
- {
- for (char n = 'a'; n <= 'e'; n++)
- {
- string word = string.Empty + i + j + k + m + n;
- long weightSeq = WeightOfSingleLetter(i);
- long index = 2;
- if (j != i)
- {
- weightSeq += WeightOfSingleLetter(j) * index;
- index++;
- }
- if (k != i && k != j)
- {
- weightSeq += WeightOfSingleLetter(k) * index;
- index++;
- }
- if (m != i && m != j && m != k)
- {
- weightSeq += WeightOfSingleLetter(m) * index;
- index++;
- }
- if (n != i && n != j && n != k && n != m)
- {
- weightSeq += WeightOfSingleLetter(n) * index;
- }
- if (weightSeq >= startNum && weightSeq <= endNum)
- {
- foundRightSequence = true;
- Console.Write("{0} ", word);
- }
- }
- }
- }
- }
- }
- if (!foundRightSequence)
- {
- Console.WriteLine("No");
- }
- }
- }
- private static long WeightOfSingleLetter(char letter)
- {
- checked
- {
- long weight = 0;
- switch (letter)
- {
- case 'a':
- weight = 5;
- break;
- case 'b':
- weight = -12;
- break;
- case 'c':
- weight = 47;
- break;
- case 'd':
- weight = 7;
- break;
- case 'e':
- weight = -32;
- break;
- }
- return weight;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement