Advertisement
fbinnzhivko

05.00 Bohemcho The Bad Ghost

Mar 16th, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.96 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. class BohemchoTheBadGhost
  5. {
  6.     static void Main()
  7.     {
  8.         string initialState = Console.ReadLine();
  9.  
  10.         long score = 0;
  11.         int lightsOn = 0;
  12.  
  13.         while (initialState != "Stop, God damn it")
  14.         {
  15.             uint currentFloor = uint.Parse(initialState);
  16.  
  17.             int[] currentRooms = Console.ReadLine().Split().Select(int.Parse).ToArray();
  18.  
  19.             for (int i = 0; i < currentRooms.Length; i++)
  20.             {
  21.                 currentFloor = currentFloor ^ (1U << currentRooms[i]);
  22.             }
  23.  
  24.             for (int i = 0; i < 32; i++)
  25.             {
  26.                 if (((currentFloor >> i) & 1) == 1)
  27.                 {
  28.                     lightsOn++;
  29.                 }
  30.             }
  31.             score += currentFloor;
  32.  
  33.             initialState = Console.ReadLine();
  34.         }
  35.  
  36.         Console.WriteLine("Bohemcho left {0} lights on and his score is {1}", lightsOn, score);
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement