Created
April 20, 2016 06:50
-
-
Save sguzunov/aea99e3de871e299d3dea9abdf1ac8c5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
class TextToNumber | |
{ | |
static void Main() | |
{ | |
long result = 0; | |
int module = int.Parse(Console.ReadLine()); | |
string text = Console.ReadLine(); | |
for (int i = 0; i < text.Length; i++) | |
{ | |
char sign = text[i]; | |
if (sign == '@') | |
{ | |
break; | |
} | |
else if ('0' <= sign && sign <= '9') | |
{ | |
result *= (sign - '0'); | |
} | |
else if ('A' <= sign && sign <= 'Z') | |
{ | |
result += (sign - 'A'); | |
} | |
else if ('a' <= sign && sign <= 'z') | |
{ | |
result += (sign - 'a'); | |
} | |
else | |
{ | |
result %= module; | |
} | |
} | |
Console.WriteLine(result); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment