Advertisement
Guest User

Untitled

a guest
Apr 14th, 2017
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.90 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Five_Special_Letters
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int start = int.Parse(Console.ReadLine());
  14.             int end = int.Parse(Console.ReadLine());
  15.             int weight = 0;
  16.             bool flag = true;
  17.             Dictionary<char, int> values = new Dictionary<char, int>();
  18.             values.Add('a', 5);
  19.             values.Add('b', -12);
  20.             values.Add('c', 47);
  21.             values.Add('d', 7);
  22.             values.Add('e', -32);
  23.  
  24.             for (char c = 'a'; c < 'f'; c++)
  25.             {
  26.                 for (char c1 = 'a'; c1 < 'f'; c1++)
  27.                 {
  28.                     for (char c2 = 'a'; c2 < 'f'; c2++)
  29.                     {
  30.                         for (char c3 = 'a'; c3 < 'f'; c3++)
  31.                         {
  32.                             for (char c4 = 'a'; c4 < 'f'; c4++)
  33.                             {
  34.                                 char[] lc = string.Format("{0}{1}{2}{3}{4}", c, c1, c2, c3, c4).ToCharArray().Distinct().ToArray();
  35.                                 weight = 0;
  36.                                 for (int ke = 1; ke <= lc.Length; ke++)
  37.                                 {
  38.                                     weight += values[lc[ke - 1]] * ke;
  39.                                 }
  40.                                 if (weight >= start && weight <= end)
  41.                                 {
  42.                                     Console.Write("{0}{1}{2}{3}{4} ", c, c1, c2, c3, c4);
  43.                                     flag = false;
  44.                                 }
  45.                             }
  46.                         }
  47.                     }
  48.                 }
  49.             }
  50.             if (flag)
  51.             {
  52.                 Console.Write("No");
  53.             }
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement