fbinnzhivko

05.02 Game of Bits

May 5th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.60 KB | None | 0 0
  1. using System;
  2. class BitsUp
  3. {
  4.     static void Main()
  5.     {
  6.         int n = int.Parse(Console.ReadLine());
  7.         int step = int.Parse(Console.ReadLine());
  8.         int counterBits = 0;
  9.         for (int i = 0; i < n; i++)
  10.         {
  11.             int num = int.Parse(Console.ReadLine());
  12.             for (int x = 7; x >= 0; x--)
  13.             {
  14.                 if ((counterBits % step == 1) || (step == 1 && counterBits > 0))
  15.                 {
  16.                     num = num | (1 << x);
  17.                 }
  18.                 counterBits++;
  19.             }
  20.             Console.WriteLine(num);
  21.         }
  22.     }
  23. }
Add Comment
Please, Sign In to add comment