Categories
Visual C# Телерик

Решение на задача – StrangeLand Numbers

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace StrangeLandNumbers {
  class Program {
    static void Main(string[] args) {
      Dictionary strangeLandNumbersDictionay = new Dictionary();
      strangeLandNumbersDictionay.Add("f", 0);
      strangeLandNumbersDictionay.Add("bIN", 1);
      strangeLandNumbersDictionay.Add("oBJEC", 2);
      strangeLandNumbersDictionay.Add("mNTRAVL", 3);
      strangeLandNumbersDictionay.Add("lPVKNQ", 4);
      strangeLandNumbersDictionay.Add("pNWE", 5);
      strangeLandNumbersDictionay.Add("hT", 6);
      List strangeLandNumbersList = new List();
      string strangeLandNumber = Console.ReadLine();
      StringBuilder number = new StringBuilder();
      for (int index = 0; index < strangeLandNumber.Length; index++) {
        number.Append(strangeLandNumber[index]);
        if (strangeLandNumbersDictionay.ContainsKey(number.ToString())) {
          strangeLandNumbersList.Add(number.ToString());
          number.Clear();
        }
      }
      int power = strangeLandNumbersList.Count - 1;
      long sum = 0;
      for (int index = 0; index < strangeLandNumbersList.Count; index++) {
        sum += strangeLandNumbersDictionay[strangeLandNumbersList[index]] * (long) Math.Pow(7, power);
        number.Clear();
        power--;
      }
      Console.WriteLine(sum);
    }
  }
}