Advertisement
VKNikov

Drunken Numbers

Apr 11th, 2014
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7.  
  8. class DrunkenNumbers
  9. {
  10.     static void Main()
  11.     {
  12.         long n = long.Parse(Console.ReadLine());
  13.         string beers = string.Empty;
  14.         int mitkoCounter = 0;
  15.         int vladkoCounter = 0;
  16.  
  17.         for (int i = 0; i < n; i++)
  18.         {
  19.             long beersCount = Math.Abs(long.Parse(Console.ReadLine()));
  20.             beers = beersCount.ToString();
  21.  
  22.             if (beers.Length % 2 == 0)
  23.             {
  24.                 for (int j = 0; j < beers.Length / 2; j++)
  25.                 {
  26.                     mitkoCounter += beers[j] - '0';
  27.                 }
  28.             }
  29.             else
  30.             {
  31.                 for (int j = 0; j < beers.Length / 2 + 1; j++)
  32.                 {
  33.                     mitkoCounter += beers[j] - '0';
  34.                 }
  35.             }
  36.  
  37.             for (int k = beers.Length - 1; k > beers.Length / 2 - 1; k--)
  38.             {
  39.                 vladkoCounter += beers[k] - '0';
  40.             }
  41.         }
  42.  
  43.         if (mitkoCounter > vladkoCounter)
  44.         {
  45.             Console.WriteLine("M {0}", mitkoCounter - vladkoCounter);
  46.         }
  47.         else if (mitkoCounter < vladkoCounter)
  48.         {
  49.             Console.WriteLine("V {0}", vladkoCounter - mitkoCounter);
  50.         }
  51.         else if (mitkoCounter == vladkoCounter)
  52.         {
  53.             Console.WriteLine("No {0}", mitkoCounter + vladkoCounter);
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement