Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- class CalcProblem23
- {
- static char system(long b)
- {
- return ((char)(b + 97));
- }
- static long sumOf(string a)
- {
- long sum = 0;
- for (int i = 0; i < a.Length; i++)
- {
- if (i + 1 == a.Length)
- {
- sum += a[i] - 'a' * 1;
- }
- else
- {
- sum += (long)(a[i] - 'a') * (long)Math.Pow(23, a.Length - i - 1);
- }
- }
- return sum;
- }
- static void toChar(long sum) {
- int pos = 0;
- List<char> b = new List<char>();
- while (true)
- {
- b.Add(system(sum % 23));
- sum = sum / 23;
- pos++;
- if (pos + 1 > 10 || sum < 1)
- {
- break;
- }
- }
- b.Reverse();
- foreach (var item in b)
- {
- Console.Write(item);
- }
- }
- static void Main(string[] args)
- {
- string[] words = Console.ReadLine().Split(' ');
- long sum = 0;
- foreach (var item in words)
- {
- sum+=sumOf(item);
- }
- toChar(sum);
- Console.Write(" = {0}",sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement