Bradara

Salt and papper

Oct 7th, 2016
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.09 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 Salt_and_Pepper
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var dishes = ulong.Parse(Console.ReadLine());
  14.             string commands = Console.ReadLine();
  15.             while (commands != "end")
  16.             {
  17.                 string[] words = commands.Split(' ');
  18.                 var spice = words[0];
  19.                 var step =int.Parse(words[1]);
  20.  
  21.                 if (spice == "pepper")
  22.                 {
  23.                     for (int i = 0; i < 64; i+=step)
  24.                     {
  25.                         dishes |= (ulong)1 << i;
  26.                     }
  27.                 }
  28.                 if (spice == "salt")
  29.                 {
  30.                     for (int i = 0; i < 64; i+=step)
  31.                     {
  32.                         dishes &= ~((ulong)1 << i);
  33.                     }
  34.                 }
  35.                 commands = Console.ReadLine();
  36.             }
  37.             Console.WriteLine(dishes);
  38.         }
  39.     }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment