Advertisement
svetoslavbozov

Durankulak Numbers

Feb 14th, 2013
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.16 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Numerics;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7.  
  8. class Program
  9. {
  10.     static void Main()
  11.     {
  12.         string number = Console.ReadLine();
  13.  
  14.         List<int> digits = new List<int>();
  15.         int bigLetter = 0;
  16.         int smallLetter = 0;
  17.  
  18.         foreach (var ch in number)
  19.         {
  20.             if ( ch > 96 && ch < 123)
  21.             {
  22.                 smallLetter = (ch - 96) * 26;
  23.             }
  24.             if ( ch >64 && ch < 91)
  25.             {
  26.                 bigLetter = ch - 65 + smallLetter;
  27.                 digits.Add(bigLetter);
  28.                 smallLetter = 0;
  29.                 bigLetter = 0;
  30.             }
  31.         }
  32.         digits.Reverse();
  33.         BigInteger result = 0;
  34.         for (int i = 0; i < digits.Count; i++)
  35.         {
  36.             result += (digits[i] * CalculatePower(i));
  37.         }
  38.  
  39.         Console.WriteLine(result);
  40.     }
  41.     static BigInteger CalculatePower(int index)
  42.     {
  43.         BigInteger pow = 1;
  44.         for (int i = 0; i < index; index--)
  45.         {
  46.             pow *= 168;
  47.         }
  48.         return pow;
  49.     }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement