svetlozar_kirkov

Multiverse Communication [Telerik] (100/100)

Nov 15th, 2014
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3.  
  4. namespace MultiverseCommunication
  5. {
  6.     class MultiverseCommunication
  7.     {
  8.         static void Main()
  9.         {
  10.             string input = Console.ReadLine();
  11.             Dictionary<string,decimal> dict = new Dictionary<string, decimal>();
  12.             dict.Add("CHU",0);
  13.             dict.Add("TEL",1);
  14.             dict.Add("OFT",2);
  15.             dict.Add("IVA",3);
  16.             dict.Add("EMY",4);
  17.             dict.Add("VNB",5);
  18.             dict.Add("POQ",6);
  19.             dict.Add("ERI",7);
  20.             dict.Add("CAD",8);
  21.             dict.Add("K-A",9);
  22.             dict.Add("IIA",10);
  23.             dict.Add("YLO",11);
  24.             dict.Add("PLA",12);
  25.             decimal result = 0M;
  26.             for (decimal i = input.Length-3, k = 1; i >= 0; i-=3,k*=13)
  27.             {
  28.                 char one = input[(int)i];
  29.                 char two = input[(int)i + 1];
  30.                 char three = input[(int)i + 2];
  31.                 string temp = one +""+ two +""+ three;
  32.                 if (dict.ContainsKey(temp))
  33.                 {
  34.                     result += k*dict[temp];
  35.                 }
  36.             }
  37.             Console.WriteLine(result);
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment