Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class BitKiller
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int step = int.Parse(Console.ReadLine());
- byte[] nums = new byte[n];
- for (int i = 0; i < n; i++)
- {
- nums[i] = byte.Parse(Console.ReadLine());
- }
- int counter = 0;
- int num = 0;
- int bytesCounter = 0;
- for (int i = 0; i < n; i++)
- {
- for (int bytes = 7; bytes >= 0; bytes--, counter++) {
- if (!(counter > 0 && (counter % step == 1 || step == 1))) {
- ++bytesCounter;
- num <<= 1;
- num |= ((nums[i] >> bytes) & 1);
- if (bytesCounter == 8) {
- bytesCounter = 0;
- Console.WriteLine(num);
- num = 0;
- }
- }
- }
- }
- if (bytesCounter != 0) {
- num <<= (8 - bytesCounter);
- Console.WriteLine(num);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement