Skip to content

Instantly share code, notes, and snippets.

@alagalia
Last active August 29, 2015 14:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alagalia/b4475711687db54039a4 to your computer and use it in GitHub Desktop.
Save alagalia/b4475711687db54039a4 to your computer and use it in GitHub Desktop.
Bits Up
using System;
class BitsUp
{
static void Main()
{
int n = int.Parse(Console.ReadLine());
int step = int.Parse(Console.ReadLine());
int counterBits = 0;
for (int i = 0; i < n; i++)
{
int num = int.Parse(Console.ReadLine());
for (int x = 7; x >= 0; x--)
{
if (counterBits == 1 | counterBits % step == 1)
{
num = num | (1 << x);
}
counterBits++;
}
Console.WriteLine(num);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment