Advertisement
Guest User

Bohemcho The Bad Ghost

a guest
Oct 18th, 2015
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3.  
  4. namespace TheBadGhost
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int lightsOnCounter = 0;
  11.             ulong finalScore = 0;
  12.             string inputString = Console.ReadLine();
  13.             while (!inputString.Contains("Stop, God damn it"))
  14.             {
  15.                 ulong floor = ulong.Parse(inputString);
  16.                 int[] apartments = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
  17.                 for (int i = 0; i < apartments.Length; i++)
  18.                 {
  19.                     floor = floor ^ (1u << apartments[i]);
  20.                 }
  21.                 for (int i = 0; i < 32; i++)
  22.                 {
  23.                     bool isBitUp = (floor >> i & 1) == 1;
  24.                     if (isBitUp)
  25.                     {
  26.                         lightsOnCounter++;
  27.                     }
  28.                 }
  29.                 finalScore += floor;
  30.                 inputString = Console.ReadLine();
  31.             }
  32.             Console.WriteLine("Bohemcho left {0} lights on and his score is {1}", lightsOnCounter, finalScore);
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement