Last active
August 29, 2015 14:17
-
-
Save alagalia/b4475711687db54039a4 to your computer and use it in GitHub Desktop.
Bits Up
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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