Advertisement
sirjordan

Drunken Numbers

Jun 24th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.33 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. class Program
  7. {
  8.     static int rounds = int.Parse(Console.ReadLine());
  9.     static int[] roundContent = new int[rounds];
  10.     static int mitkoScore = 0;
  11.     static int vladkoScrore = 0;
  12.     static int allDrinkenBeer = 0;
  13.     // TODO: May tool long for an INT, may become Long;
  14.  
  15.     static void Main()
  16.     {
  17.        
  18.         for (int i = 0; i < rounds; i++)
  19.         {
  20.             roundContent[i] = int.Parse(Console.ReadLine());
  21.         }
  22.  
  23.         for (int i = 0; i < roundContent.Length; i++)
  24.         {
  25.             CountBeers(roundContent[i].ToString());
  26.         }
  27.  
  28.         //Console.WriteLine(mitkoScore);
  29.         //Console.WriteLine(vladkoScrore);
  30.         if (mitkoScore > vladkoScrore)
  31.         {
  32.             int diff = mitkoScore - vladkoScrore;
  33.             Console.WriteLine("M " + diff);
  34.         }
  35.         else if (vladkoScrore > mitkoScore)
  36.         {
  37.             int diff = vladkoScrore - mitkoScore;
  38.             Console.WriteLine("V " + diff);
  39.         }
  40.         else
  41.         {
  42.             int eq = mitkoScore + vladkoScrore;
  43.             Console.WriteLine("No " + eq);
  44.         }
  45.        
  46.     }
  47.  
  48.     static void CountBeers(string drinkingRound)
  49.     {
  50.         int mitkoTemp = 0;
  51.         int vladkoTemp = 0;
  52.         if (drinkingRound.Length % 2 == 0)
  53.         {
  54.             // Mitko's beers
  55.             for (int i = 0; i < drinkingRound.Length / 2; i++)
  56.             {
  57.                 mitkoTemp += drinkingRound[i] - '0';
  58.             }
  59.             // Vladko
  60.             for (int i = drinkingRound.Length / 2; i < drinkingRound.Length; i++)
  61.             {
  62.                 vladkoTemp += drinkingRound[i] - '0';
  63.             }
  64.             mitkoScore += mitkoTemp;
  65.             vladkoScrore += vladkoTemp;
  66.         }
  67.         else
  68.         {
  69.             // Mitko's beers
  70.             for (int i = 0; i < drinkingRound.Length / 2 + 1; i++)
  71.             {
  72.                 mitkoTemp += drinkingRound[i] - '0';
  73.             }
  74.             // Vladko
  75.             for (int i = drinkingRound.Length / 2; i < drinkingRound.Length; i++)
  76.             {
  77.                 vladkoTemp += drinkingRound[i] - '0';
  78.             }
  79.             mitkoScore += mitkoTemp;
  80.             vladkoScrore += vladkoTemp;
  81.         }
  82.         // 2 000 000 000
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement