Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class SecretNumber
- {
- static void Main()
- {
- string N = Console.ReadLine();
- int specialSum = 0;
- char[] myArr = new char[N.Length - 1];
- if (N[0] == '-')
- {
- for (int i = 0; i < N.Length - 1; i++)
- {
- myArr[i] = N[i + 1];
- }
- N = new string(myArr);
- }
- int count = 0;
- int value = 0;
- for (int i = N.Length - 1; i >= 0; i--)
- {
- count++;
- value = int.Parse(N[i].ToString());
- if (count % 2 == 1)
- {
- specialSum += value * (int)Math.Pow(count, 2);
- }
- else
- {
- specialSum += (int)Math.Pow(value,2) * count;
- }
- }
- Console.WriteLine(specialSum);
- int lastDigit = 0;
- lastDigit = specialSum % 10;
- int R = specialSum % 26 + 1;
- char letter = '\0';
- int next = R - 1;
- if (lastDigit == 0)
- {
- Console.WriteLine("{0} has no secret alpha-sequence", N);
- }
- else
- {
- for (int i = 0; i < lastDigit; i++)
- {
- letter = (char)(65 + next);
- Console.Write("{0}", letter);
- next++;
- if (letter == 'Z')
- {
- next = 0;
- }
- }
- }
- Console.WriteLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement