Advertisement
Guest User

Bohemcho The Bad Ghost

a guest
Oct 19th, 2015
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.24 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. namespace Problem5
  8. {
  9.     class Problem5
  10.     {
  11.         static void Main()
  12.         {
  13.             string command = Console.ReadLine();
  14.             int counter = 0;
  15.             ulong floor = 0;
  16.             ulong score = 0;
  17.  
  18.             while (command != "Stop, God damn it")
  19.             {
  20.                 floor = ulong.Parse(command);
  21.  
  22.  
  23.                 string oddinput = Console.ReadLine();
  24.  
  25.                 int[] apartments = oddinput.Split(' ').Select(int.Parse).ToArray();
  26.  
  27.  
  28.                 for (int i = 0; i < apartments.Length; i++)
  29.                 {
  30.  
  31.                     floor = floor ^ (1ul << apartments[i]);
  32.  
  33.                 }
  34.  
  35.                 for (int i = 0; i < 32; i++)
  36.                 {
  37.                     ulong mask = (floor >> i) & 1;
  38.  
  39.                     if (mask == 1)
  40.                     {
  41.                         counter++;
  42.                     }
  43.                 }
  44.  
  45.                 score += floor;
  46.  
  47.                 command = Console.ReadLine();
  48.             }
  49.  
  50.  
  51.             Console.WriteLine("Bohemcho left {0} lights on and his score is {1}", counter, score);
  52.      
  53.  
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement