Advertisement
Guest User

Encoding sum

a guest
Feb 5th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.55 KB | None | 0 0
  1. using System;
  2. class Program
  3. {
  4.     static void Main()
  5.     {
  6.         int m = Int32.Parse(Console.ReadLine());
  7.         string input = Console.ReadLine().ToLower();
  8.         long result = 0;
  9.         for (int i = 0; i < input.Length; i++)
  10.         {
  11.             if (input[i] == '@')
  12.             {
  13.                 Console.WriteLine(result); return;
  14.             }
  15.             else if (input[i] >= '0' && input[i] <= '9') result *= input[i] - '0';
  16.             else if (input[i] >= 'a' && input[i] <= 'z') result += input[i] - 'a';
  17.             else result %= m;
  18.         }
  19.     }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement